-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[libc++][C++03] Split libc++-specific tests for the frozen headers #144093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
You can test this locally with the following command:darker --check --diff -r HEAD~1...HEAD libcxx/test/libcxx-03/clang_tidy.gen.py libcxx/test/libcxx-03/lint/lint_headers.sh.py libcxx/test/libcxx-03/module_std.gen.py libcxx/test/libcxx-03/module_std_compat.gen.py libcxx/test/libcxx-03/no_assert_include.gen.py libcxx/test/libcxx-03/system_reserved_names.gen.py libcxx/test/libcxx-03/transitive_includes.gen.py libcxx/test/libcxx-03/transitive_includes/to_csv.py View the diff from darker here.--- clang_tidy.gen.py 2025-08-11 09:34:10.000000 +0000
+++ clang_tidy.gen.py 2025-08-11 09:37:26.403745 +0000
@@ -13,15 +13,21 @@
# block Lit from interpreting a RUN/XFAIL/etc inside the generation script
# END.
import sys
+
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
+from libcxx.header_information import (
+ lit_header_restrictions,
+ lit_header_undeprecations,
+ public_headers,
+)
for header in public_headers:
- print(f"""\
+ print(
+ f"""\
//--- {header}.sh.cpp
// REQUIRES: has-clang-tidy
// The frozen headers should not be updated to the latest libc++ style, so don't test.
@@ -35,6 +41,7 @@
// TODO: run clang-tidy with modules enabled once they are supported
// RUN: %{{clang-tidy}} %s --warnings-as-errors=* -header-filter=.* --config-file=%{{libcxx-dir}}/.clang-tidy --load=%{{test-tools-dir}}/clang_tidy_checks/libcxx-tidy.plugin -- -Wweak-vtables %{{compile_flags}} -fno-modules
#include <{header}>
-""")
+"""
+ )
--- transitive_includes/to_csv.py 2025-08-11 09:34:10.000000 +0000
+++ transitive_includes/to_csv.py 2025-08-11 09:37:26.479642 +0000
@@ -14,13 +14,16 @@
import os
import pathlib
import re
import sys
-libcxx_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
+libcxx_root = os.path.dirname(
+ os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+)
sys.path.append(os.path.join(libcxx_root, "utils"))
from libcxx.header_information import Header
+
def parse_line(line: str) -> Tuple[int, str]:
"""
Parse a single line of --trace-includes output.
@@ -31,10 +34,11 @@
raise ArgumentError(f"Line {line} contains invalid data.")
# The number of periods in front of the header name is the nesting level of
# that header.
return (len(match.group(1)), match.group(2))
+
def make_cxx_v1_relative(header: str) -> Optional[str]:
"""
Returns the path of the header as relative to <whatever>/c++/v1, or None if the path
doesn't contain c++/v1.
@@ -51,10 +55,11 @@
match = re.match(CXX_V1_REGEX, header)
if not match:
return None
else:
return match.group(1)
+
def parse_file(file: io.TextIOBase) -> List[Tuple[Header, Header]]:
"""
Parse a file containing --trace-includes output to generate a list of the
transitive includes contained in it.
@@ -79,25 +84,27 @@
else:
assert includer is not None
result.append((includer, Header(relative)))
return result
+
def print_csv(includes: List[Tuple[Header, Header]]) -> None:
"""
Print the transitive includes as space-delimited CSV.
This function only prints public libc++ headers that are not C compatibility headers.
"""
# Sort and group by includer
by_includer = lambda t: t[0]
includes = itertools.groupby(sorted(includes, key=by_includer), key=by_includer)
- for (includer, includees) in includes:
+ for includer, includees in includes:
includees = map(lambda t: t[1], includees)
for h in sorted(set(includees)):
if h.is_public() and not h.is_C_compatibility():
print(f"{includer} {h}")
+
def main(argv):
parser = argparse.ArgumentParser(
description="""
Given a list of headers produced by --trace-includes, produce a list of libc++ headers in that output.
@@ -106,15 +113,22 @@
information for this script to run.
The output of this script is provided in space-delimited CSV format where each line contains:
<header performing inclusion> <header being included>
- """)
- parser.add_argument("inputs", type=argparse.FileType("r"), nargs='+', default=None,
- help="One or more files containing the result of --trace-includes")
+ """
+ )
+ parser.add_argument(
+ "inputs",
+ type=argparse.FileType("r"),
+ nargs="+",
+ default=None,
+ help="One or more files containing the result of --trace-includes",
+ )
args = parser.parse_args(argv)
includes = [line for file in args.inputs for line in parse_file(file)]
print_csv(includes)
+
if __name__ == "__main__":
main(sys.argv[1:])
--- transitive_includes.gen.py 2025-08-11 09:34:10.000000 +0000
+++ transitive_includes.gen.py 2025-08-11 09:37:26.496375 +0000
@@ -20,10 +20,11 @@
# block Lit from interpreting a RUN/XFAIL/etc inside the generation script
# END.
import sys
+
sys.path.append(sys.argv[1])
from libcxx.header_information import lit_header_restrictions, public_headers
import re
|
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesThe C++03 headers are essentially a separate implementation, so it doesn't make a ton of sense to try to test two implementations with a single set of implementation-specific tests. Most of the tests will be removed in a follow-up, since they don't run in C++03 mode. This patch adds them to make as few changes to the copy as possible. The most notable changes are that This also modifies This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc. Patch is 2.92 MiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/144093.diff 921 Files Affected:
diff --git a/libcxx/test/libcxx-03/Wnon_modular_include_in_module.compile.pass.cpp b/libcxx/test/libcxx-03/Wnon_modular_include_in_module.compile.pass.cpp
new file mode 100644
index 0000000000000..aa7a6d98d7d68
--- /dev/null
+++ b/libcxx/test/libcxx-03/Wnon_modular_include_in_module.compile.pass.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: target={{.*}}-apple-{{.*}}
+// UNSUPPORTED: c++03
+
+// This test ensures that libc++ supports being compiled with modules enabled and with
+// -Wnon-modular-include-in-module. This effectively checks that we don't include any
+// non-modular header from the library.
+//
+// Since most underlying platforms are not modularized properly, this test currently only
+// works on Apple platforms.
+
+// ADDITIONAL_COMPILE_FLAGS: -Wnon-modular-include-in-module -Wsystem-headers-in-module=std -fmodules -fcxx-modules
+
+#include <vector>
diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
new file mode 100644
index 0000000000000..4e51014f20b18
--- /dev/null
+++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class RandomAccessIterator>
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
+//
+// template <class RandomAccessIterator, class RandomNumberGenerator>
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
+// RandomNumberGenerator& rand);
+
+//
+// In C++17, random_shuffle has been removed.
+// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+// is defined before including <algorithm>, then random_shuffle will be restored.
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
+
+#include <algorithm>
+#include <cstddef>
+#include <vector>
+
+#include "test_macros.h"
+
+struct gen
+{
+ std::ptrdiff_t operator()(std::ptrdiff_t n)
+ {
+ return n-1;
+ }
+};
+
+
+int main(int, char**)
+{
+ std::vector<int> v;
+ std::random_shuffle(v.begin(), v.end());
+ gen r;
+ std::random_shuffle(v.begin(), v.end(), r);
+
+ return 0;
+}
diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.verify.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.verify.cpp
new file mode 100644
index 0000000000000..057f126a93cfe
--- /dev/null
+++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.depr_in_cxx14.verify.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template <class RandomAccessIterator>
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last);
+//
+// template <class RandomAccessIterator, class RandomNumberGenerator>
+// void
+// random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
+// RandomNumberGenerator& rand);
+
+// UNSUPPORTED: c++03, c++11
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
+
+#include <algorithm>
+#include <cstddef>
+
+#include "test_macros.h"
+
+struct gen
+{
+ std::ptrdiff_t operator()(std::ptrdiff_t n)
+ {
+ return n-1;
+ }
+};
+
+
+void f() {
+ int v[1] = {1};
+ std::random_shuffle(&v[0], &v[1]); // expected-warning {{'random_shuffle<int *>' is deprecated}}
+ gen r;
+ std::random_shuffle(&v[0], &v[1], r); // expected-warning {{'random_shuffle<int *, gen &>' is deprecated}}
+}
diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp
new file mode 100644
index 0000000000000..0c5ae84d97700
--- /dev/null
+++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_nontrivial.pass.cpp
@@ -0,0 +1,331 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// In the modules build, adding another overload of `memmove` doesn't work.
+// UNSUPPORTED: clang-modules-build
+// GCC complains about "ambiguating" `__builtin_memmove`.
+// UNSUPPORTED: gcc
+
+// <algorithm>
+
+#include <cassert>
+#include <cstddef>
+
+// These tests check that `std::copy` and `std::move` (including their variations like `copy_n`) don't forward to
+// `std::memmove` when doing so would be observable.
+
+// This template is a better match than the actual `builtin_memmove` (it can match the pointer type exactly, without an
+// implicit conversion to `void*`), so it should hijack the call inside `std::copy` and similar algorithms if it's made.
+template <class Dst, class Src>
+constexpr void* __builtin_memmove(Dst*, Src*, std::size_t) {
+ assert(false);
+ return nullptr;
+}
+
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <iterator>
+#include <ranges>
+#include <type_traits>
+
+#include "test_iterators.h"
+#include "test_macros.h"
+
+// S1 and S2 are simple structs that are convertible to each other and have the same bit representation.
+struct S1 {
+ int x;
+
+ constexpr S1() = default;
+ constexpr S1(int set_x) : x(set_x) {}
+
+ friend constexpr bool operator==(const S1& lhs, const S1& rhs) { return lhs.x == rhs.x; }
+};
+
+struct S2 {
+ int x;
+
+ constexpr S2() = default;
+ constexpr S2(int set_x) : x(set_x) {}
+ constexpr S2(S1 from) : x(from.x) {}
+
+ friend constexpr bool operator==(const S1& lhs, const S2& rhs) { return lhs.x == rhs.x; }
+ friend constexpr bool operator==(const S2& lhs, const S2& rhs) { return lhs.x == rhs.x; }
+};
+
+// U1 and U2 are simple unions that are convertible to each other and have the same bit representation.
+union U1 {
+ int x;
+
+ constexpr U1() = default;
+ constexpr U1(int set_x) : x(set_x) {}
+
+ friend constexpr bool operator==(const U1& lhs, const U1& rhs) { return lhs.x == rhs.x; }
+};
+
+union U2 {
+ int x;
+
+ constexpr U2() = default;
+ constexpr U2(int set_x) : x(set_x) {}
+ constexpr U2(U1 from) : x(from.x) {}
+
+ friend constexpr bool operator==(const U1& lhs, const U2& rhs) { return lhs.x == rhs.x; }
+ friend constexpr bool operator==(const U2& lhs, const U2& rhs) { return lhs.x == rhs.x; }
+};
+
+struct NonTrivialMoveAssignment {
+ int i;
+
+ constexpr NonTrivialMoveAssignment() = default;
+ constexpr NonTrivialMoveAssignment(int set_i) : i(set_i) {}
+
+ constexpr NonTrivialMoveAssignment(NonTrivialMoveAssignment&& rhs) = default;
+ constexpr NonTrivialMoveAssignment& operator=(NonTrivialMoveAssignment&& rhs) noexcept {
+ i = rhs.i;
+ return *this;
+ }
+
+ constexpr friend bool operator==(const NonTrivialMoveAssignment&, const NonTrivialMoveAssignment&) = default;
+};
+
+static_assert(!std::is_trivially_move_assignable_v<NonTrivialMoveAssignment>);
+static_assert(!std::is_trivially_assignable<NonTrivialMoveAssignment&, NonTrivialMoveAssignment&>::value);
+
+struct NonTrivialMoveCtr {
+ int i;
+
+ constexpr NonTrivialMoveCtr() = default;
+ constexpr NonTrivialMoveCtr(int set_i) : i(set_i) {}
+
+ constexpr NonTrivialMoveCtr(NonTrivialMoveCtr&& rhs) noexcept : i(rhs.i) {}
+ constexpr NonTrivialMoveCtr& operator=(NonTrivialMoveCtr&& rhs) = default;
+
+ constexpr friend bool operator==(const NonTrivialMoveCtr&, const NonTrivialMoveCtr&) = default;
+};
+
+static_assert(std::is_trivially_move_assignable_v<NonTrivialMoveCtr>);
+static_assert(!std::is_trivially_copyable_v<NonTrivialMoveCtr>);
+
+struct NonTrivialCopyAssignment {
+ int i;
+
+ constexpr NonTrivialCopyAssignment() = default;
+ constexpr NonTrivialCopyAssignment(int set_i) : i(set_i) {}
+
+ constexpr NonTrivialCopyAssignment(const NonTrivialCopyAssignment& rhs) = default;
+ constexpr NonTrivialCopyAssignment& operator=(const NonTrivialCopyAssignment& rhs) {
+ i = rhs.i;
+ return *this;
+ }
+
+ constexpr friend bool operator==(const NonTrivialCopyAssignment&, const NonTrivialCopyAssignment&) = default;
+};
+
+static_assert(!std::is_trivially_copy_assignable_v<NonTrivialCopyAssignment>);
+
+struct NonTrivialCopyCtr {
+ int i;
+
+ constexpr NonTrivialCopyCtr() = default;
+ constexpr NonTrivialCopyCtr(int set_i) : i(set_i) {}
+
+ constexpr NonTrivialCopyCtr(const NonTrivialCopyCtr& rhs) : i(rhs.i) {}
+ constexpr NonTrivialCopyCtr& operator=(const NonTrivialCopyCtr& rhs) = default;
+
+ constexpr friend bool operator==(const NonTrivialCopyCtr&, const NonTrivialCopyCtr&) = default;
+};
+
+static_assert(std::is_trivially_copy_assignable_v<NonTrivialCopyCtr>);
+static_assert(!std::is_trivially_copyable_v<NonTrivialCopyCtr>);
+
+template <class T>
+constexpr T make(int from) {
+ return T(from);
+}
+
+template <typename PtrT, typename T = std::remove_pointer_t<PtrT>>
+static T make_internal_array[5] = {T(), T(), T(), T(), T()};
+
+template <class T>
+requires std::is_pointer_v<T>
+constexpr T make(int i) {
+ if constexpr (!std::same_as<std::remove_pointer_t<T>, void>) {
+ return make_internal_array<T> + i;
+ } else {
+ return make_internal_array<int> + i;
+ }
+}
+
+template <class InIter, template <class> class SentWrapper, class OutIter, class Func>
+constexpr void test_one(Func func) {
+ using From = typename std::iterator_traits<InIter>::value_type;
+ using To = typename std::iterator_traits<OutIter>::value_type;
+
+ {
+ const std::size_t N = 5;
+
+ From input[N] = {make<From>(0), make<From>(1), make<From>(2), make<From>(3), make<From>(4)};
+ To output[N];
+
+ auto in = InIter(input);
+ auto in_end = InIter(input + N);
+ auto sent = SentWrapper<decltype(in_end)>(in_end);
+ auto out = OutIter(output);
+
+ func(in, sent, out, N);
+ if constexpr (!std::same_as<To, bool>) {
+ assert(std::equal(input, input + N, output));
+ } else {
+ bool expected[N] = {false, true, true, true, true};
+ assert(std::equal(output, output + N, expected));
+ }
+ }
+
+ {
+ const std::size_t N = 0;
+
+ From input[1] = {make<From>(1)};
+ To output[1] = {make<To>(2)};
+
+ auto in = InIter(input);
+ auto in_end = InIter(input + N);
+ auto sent = SentWrapper<decltype(in_end)>(in_end);
+ auto out = OutIter(output);
+
+ func(in, sent, out, N);
+ assert(output[0] == make<To>(2));
+ }
+}
+
+template <class InIter, template <class> class SentWrapper, class OutIter>
+constexpr void test_copy() {
+ // Classic.
+ if constexpr (std::same_as<InIter, SentWrapper<InIter>>) {
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto last, auto out, std::size_t) {
+ std::copy(first, last, out);
+ });
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto last, auto out, std::size_t n) {
+ std::copy_backward(first, last, out + n);
+ });
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto, auto out, std::size_t n) {
+ std::copy_n(first, n, out);
+ });
+ }
+
+ // Ranges.
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto last, auto out, std::size_t) {
+ std::ranges::copy(first, last, out);
+ });
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto last, auto out, std::size_t n) {
+ std::ranges::copy_backward(first, last, out + n);
+ });
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto, auto out, std::size_t n) {
+ std::ranges::copy_n(first, n, out);
+ });
+}
+
+template <class InIter, template <class> class SentWrapper, class OutIter>
+constexpr void test_move() {
+ if constexpr (std::same_as<InIter, SentWrapper<InIter>>) {
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto last, auto out, std::size_t) {
+ std::move(first, last, out);
+ });
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto last, auto out, std::size_t n) {
+ std::move_backward(first, last, out + n);
+ });
+ }
+
+ // Ranges.
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto last, auto out, std::size_t) {
+ std::ranges::move(first, last, out);
+ });
+ test_one<InIter, SentWrapper, OutIter>([](auto first, auto last, auto out, std::size_t n) {
+ std::ranges::move_backward(first, last, out + n);
+ });
+}
+
+template <class From, class To = From>
+constexpr void test_copy_with_type() {
+ using FromIter = contiguous_iterator<From*>;
+ using ToIter = contiguous_iterator<To*>;
+
+ test_copy<FromIter, std::type_identity_t, ToIter>();
+ test_copy<FromIter, sized_sentinel, ToIter>();
+ test_copy<FromIter, std::type_identity_t, To*>();
+ test_copy<From*, std::type_identity_t, To*>();
+ test_copy<From*, std::type_identity_t, ToIter>();
+}
+
+template <class From, class To = From>
+constexpr void test_move_with_type() {
+ using FromIter = contiguous_iterator<From*>;
+ using ToIter = contiguous_iterator<To*>;
+
+ test_move<FromIter, std::type_identity_t, ToIter>();
+ test_move<FromIter, sized_sentinel, ToIter>();
+ test_move<FromIter, std::type_identity_t, To*>();
+ test_move<From*, std::type_identity_t, To*>();
+ test_move<From*, std::type_identity_t, ToIter>();
+}
+
+template <class From, class To>
+constexpr void test_copy_and_move() {
+ test_copy_with_type<From, To>();
+ test_move_with_type<From, To>();
+}
+
+template <class From, class To>
+constexpr void test_both_directions() {
+ test_copy_and_move<From, To>();
+ if (!std::same_as<From, To>) {
+ test_copy_and_move<To, From>();
+ }
+}
+
+constexpr bool test() {
+ test_copy_with_type<NonTrivialCopyAssignment>();
+ test_move_with_type<NonTrivialMoveAssignment>();
+
+ // Copying from a smaller type into a larger type and vice versa.
+ test_both_directions<char, int>();
+ test_both_directions<std::int32_t, std::int64_t>();
+
+ // Copying between types with different representations.
+ test_both_directions<int, float>();
+ // Copying from `bool` to `char` will invoke the optimization, so only check one direction.
+ test_copy_and_move<char, bool>();
+
+ // Copying between different structs with the same representation (there is no way to guarantee the representation is
+ // the same).
+ test_copy_and_move<S1, S2>();
+ // Copying between different unions with the same representation.
+ test_copy_and_move<U1, U2>();
+
+ // Copying from a regular pointer to a void pointer (these are not considered trivially copyable).
+ test_copy_and_move<int*, void*>();
+ // Copying from a non-const pointer to a const pointer (these are not considered trivially copyable).
+ test_copy_and_move<int*, const int*>();
+
+ // `memmove` does not support volatile pointers.
+ // (See also https://github.com/llvm/llvm-project/issues/28901).
+ if (!std::is_constant_evaluated()) {
+ test_both_directions<volatile int, int>();
+ test_both_directions<volatile int, volatile int>();
+ }
+
+ return true;
+}
+
+int main(int, char**) {
+ test();
+ static_assert(test());
+
+ return 0;
+}
diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp
new file mode 100644
index 0000000000000..ff10c7919200d
--- /dev/null
+++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/copy_move_trivial.pass.cpp
@@ -0,0 +1,334 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+// In the modules build, adding another overload of `memmove` doesn't work.
+// UNSUPPORTED: clang-modules-build
+// GCC complains about "ambiguating" `__builtin_memmove`.
+// UNSUPPORTED: gcc
+
+// <algorithm>
+
+// These tests check that `std::copy` and `std::move` (including their variations like `copy_n`) forward to
+// `memmove` when possible.
+
+#include <cstddef>
+
+struct Foo {
+ int i = 0;
+
+ Foo() = default;
+ Foo(int set_i) : i(set_i) {}
+
+ friend bool operator==(const Foo&, const Foo&) = default;
+};
+
+static bool memmove_called = false;
+
+// This template is a better match than the actual `builtin_memmove` (it can match the pointer type exactly, without an
+// implicit conversion to `void*`), so it should hijack the call inside `std::copy` and similar algorithms if it's made.
+template <class Dst, class Src>
+constexpr void* __builtin_memmove(Dst* dst, Src* src, std::size_t count) {
+ memmove_called = true;
+ return __builtin_memmove(static_cast<void*>(dst), static_cast<const void*>(src), count);
+}
+
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <iterator>
+#include <limits>
+#include <ranges>
+#include <type_traits>
+
+#include "test_iterators.h"
+
+static_assert(std::is_trivially_copyable_v<Foo>);
+
+// To test pointers to functions.
+void Func() {}
+using FuncPtr = decltype(&Func);
+
+// To test pointers to members.
+struct S {
+ int mem_obj = 0;
+ void MemFunc() {}
+};
+using MemObjPtr = decltype(&S::mem_obj);
+using MemFuncPtr = decltype(&S::MemFunc);
+
+// To test bitfields.
+struct BitfieldS {
+ unsigned char b1 : 3;
+ unsigned char : 2;
+ unsigned char b2 : 5;
+ friend bool operator==(const BitfieldS&, const BitfieldS&) = default;
+};
+
+// To test non-default alignment.
+struct AlignedS {
+ alignas(64) int x;
+ alignas(8) int y;
+ friend bool operator==(const AlignedS&, const AlignedS&) = default;
+};
+
+template <class T>
+T make(int from) {
+ return T(from);
+}
+
+template <class T>
+requires (std::is_pointer_v<T> && !std::is_function_v<std::remove_pointer_t<T>>)
+T make(int i) {
+ static std::remove_pointer_t<T> arr[8];
+ return arr + i;
+}
+
+template <class T>
+requires std::same_as<T, FuncPtr>
+FuncPtr make(int) {
+ return &Func;
+}
+
+template <class T>
+requires std::same_as<T, MemObjPtr>
+MemObjPtr make(int) {
+ return &S::mem_obj;
+}
+
+template <class T>
+requires std::same_as<T, MemFuncPtr>
+MemFuncPtr make(int) {
+ return &S::MemFunc;
+}
+
+template <class T>
+requires std::same_as<T, BitfieldS>
+BitfieldS make(int x) {
+ BitfieldS result = {};
+ result.b1 = x;
+ result.b2 = x;
+ return result;
+}
+
+template <class T>
+requires std::same_as<T, AlignedS>
+AlignedS make(int x) {
+ AlignedS result;
+ result.x = x;
+ result.y = x;
+ return result;
+}
+
+template <class InIter, template <class> class SentWrapper, class OutIter, class Func>
+void test_one(Func func) {
+ using From = std::iter_value_t<InIter>;
+ using To = std::iter_value_t<OutIter>;
+
+ // Normal case.
+ {
+ const std::size_t N = 4;
+
+ From input[N] = {make<From>(1), make<From>(2), make<From>(3), make<From>(4)...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please also make a pass to get all of the implementation-detail tests that were removed since the headers were frozen, and re-add those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussing this some more, we decided to reorganize a few parts of libcxx/test/libcxx before we actually make a copy. I have partially reviewed what needs to be split out and marked where I left it at.
libcxx/test/libcxx-03/language.support/support.types/cstddef.compile.pass.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove all of the tests that contain UNSUPPORTED: c++03
from this patch to make it easier to review.
@@ -0,0 +1,63 @@ | |||
# RUN: %{python} %s | |||
|
|||
# Verify that each run of consecutive #include directives |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be split out or removed since we have a clang-tidy check for that.
Note that this also checks for #pragma system_header
even though that's not documented in the comment.
...03/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/numerics/c.math/fdelayed-template-parsing.pass.cpp
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,18 @@ | |||
//===----------------------------------------------------------------------===// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't have any corresponding test for other carve outs, I'd be OK with removing this test entirely.
libcxx/test/libcxx-03/numerics/rand/rand.req.urng/valid_int_type.verify.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/numerics/rand/rand.req.urng/valid_real_type.verify.cpp
Outdated
Show resolved
Hide resolved
430667f
to
3daee65
Compare
libcxx/test/libcxx-03/containers/associative/map/scary.compile.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/containers/associative/set/scary.compile.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/containers/associative/unord.map/scary.compile.pass.cpp
Outdated
Show resolved
Hide resolved
...xx/test/libcxx-03/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/depr/depr.c.headers/math_h.compile.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/depr/depr.c.headers/stdint_h.std_types_t.compile.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/depr/depr.c.headers/stdint_h.xopen_source.compile.pass.cpp
Outdated
Show resolved
Hide resolved
fd34405
to
e657e64
Compare
libcxx/test/libcxx-03/experimental/fexperimental-library.compile.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.cons/wchar_pointer.pass.cpp
Outdated
Show resolved
Hide resolved
...est/libcxx-03/input.output/file.streams/fstreams/fstream.members/open_wchar_pointer.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/utilities/meta/stress_tests/stress_test_variant_overloads_impl.sh.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/utilities/template.bitset/includes.pass.cpp
Outdated
Show resolved
Hide resolved
libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/pair.incomplete.compile.pass.cpp
Outdated
Show resolved
Hide resolved
6ad2ebd
to
fa20ffb
Compare
fa20ffb
to
e751f17
Compare
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp libcxx/test/libcxx-03/algorithms/bad_iterator_traits.verify.cpp libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp libcxx/test/libcxx-03/algorithms/pstl.libdispatch.chunk_partitions.pass.cpp libcxx/test/libcxx-03/algorithms/robust_against_copying_comparators.pass.cpp libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp libcxx/test/libcxx-03/algorithms/robust_against_using_non_transparent_comparators.pass.cpp libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp libcxx/test/libcxx-03/assertions/customize_verbose_abort.link-time.pass.cpp libcxx/test/libcxx-03/assertions/default_verbose_abort.pass.cpp libcxx/test/libcxx-03/assertions/modes/hardening_mode_incorrect_value.sh.cpp libcxx/test/libcxx-03/assertions/modes/none.pass.cpp libcxx/test/libcxx-03/assertions/single_expression.pass.cpp libcxx/test/libcxx-03/atomics/atomics.order/memory_order.underlying_type.pass.cpp libcxx/test/libcxx-03/atomics/atomics.syn/incompatible_with_stdatomic.verify.cpp libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp libcxx/test/libcxx-03/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp libcxx/test/libcxx-03/atomics/diagnose_invalid_memory_order.verify.cpp libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.compile.pass.cpp libcxx/test/libcxx-03/atomics/stdatomic.h.syn/dont_hijack_header.cxx23.compile.pass.cpp libcxx/test/libcxx-03/containers/associative/map/at.abort.pass.cpp libcxx/test/libcxx-03/containers/associative/map/at.const.abort.pass.cpp libcxx/test/libcxx-03/containers/associative/reference_comparator_abi.compile.pass.cpp libcxx/test/libcxx-03/containers/associative/tree_balance_after_insert.pass.cpp libcxx/test/libcxx-03/containers/associative/tree_key_value_traits.pass.cpp libcxx/test/libcxx-03/containers/associative/tree_left_rotate.pass.cpp libcxx/test/libcxx-03/containers/associative/tree_remove.pass.cpp libcxx/test/libcxx-03/containers/associative/tree_right_rotate.pass.cpp libcxx/test/libcxx-03/containers/associative/unord.map/abi.compile.pass.cpp libcxx/test/libcxx-03/containers/associative/unord.set/abi.compile.pass.cpp libcxx/test/libcxx-03/containers/container_traits.compile.pass.cpp libcxx/test/libcxx-03/containers/sequences/array/triviality.pass.cpp libcxx/test/libcxx-03/containers/sequences/deque/abi.compile.pass.cpp libcxx/test/libcxx-03/containers/sequences/deque/asan.pass.cpp libcxx/test/libcxx-03/containers/sequences/deque/asan_caterpillar.pass.cpp libcxx/test/libcxx-03/containers/sequences/deque/segmented_iterator.compile.pass.cpp libcxx/test/libcxx-03/containers/sequences/list/abi.compile.pass.cpp libcxx/test/libcxx-03/containers/sequences/vector.bool/abi.compile.pass.cpp libcxx/test/libcxx-03/containers/sequences/vector/abi.compile.pass.cpp libcxx/test/libcxx-03/containers/sequences/vector/asan.pass.cpp libcxx/test/libcxx-03/containers/sequences/vector/asan_throw.pass.cpp libcxx/test/libcxx-03/containers/sequences/vector/invalid_allocator.verify.cpp libcxx/test/libcxx-03/containers/unord/key_value_traits.pass.cpp libcxx/test/libcxx-03/containers/unord/next_prime.pass.cpp libcxx/test/libcxx-03/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/address.cxx20.pass.cpp libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/allocate.cxx20.pass.cpp libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/construct.cxx20.pass.cpp libcxx/test/libcxx-03/depr/depr.default.allocator/allocator.members/max_size.cxx20.pass.cpp libcxx/test/libcxx-03/depr/depr.default.allocator/allocator_types.cxx20.pass.cpp libcxx/test/libcxx-03/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp libcxx/test/libcxx-03/depr/exception.unexpected/get_unexpected.pass.cpp libcxx/test/libcxx-03/depr/exception.unexpected/set_unexpected.pass.cpp libcxx/test/libcxx-03/depr/exception.unexpected/unexpected.pass.cpp libcxx/test/libcxx-03/diagnostics/system_error_win_codes.pass.cpp libcxx/test/libcxx-03/input.output/file.streams/fstreams/filebuf/traits_mismatch.verify.cpp libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp libcxx/test/libcxx-03/input.output/file.streams/fstreams/traits_mismatch.verify.cpp libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp libcxx/test/libcxx-03/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp libcxx/test/libcxx-03/input.output/string.streams/stringbuf/const_sso_buffer.pass.cpp libcxx/test/libcxx-03/input.output/string.streams/traits_mismatch.verify.cpp libcxx/test/libcxx-03/iterators/aliasing_iterator.pass.cpp libcxx/test/libcxx-03/iterators/bounded_iter/arithmetic.pass.cpp libcxx/test/libcxx-03/iterators/bounded_iter/comparison.pass.cpp libcxx/test/libcxx-03/iterators/bounded_iter/pointer_traits.pass.cpp libcxx/test/libcxx-03/iterators/bounded_iter/types.compile.pass.cpp libcxx/test/libcxx-03/iterators/contiguous_iterators.conv.compile.pass.cpp libcxx/test/libcxx-03/iterators/contiguous_iterators.pass.cpp libcxx/test/libcxx-03/iterators/contiguous_iterators.verify.cpp libcxx/test/libcxx-03/iterators/iterator.primitives/iterator.operations/prev.verify.cpp libcxx/test/libcxx-03/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/get_container.pass.cpp libcxx/test/libcxx-03/iterators/unwrap_iter.pass.cpp libcxx/test/libcxx-03/language.support/support.dynamic/libcpp_deallocate.sh.cpp libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.apple.compile.pass.cpp libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.merged.sh.cpp libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.unmerged.sh.cpp libcxx/test/libcxx-03/libcpp_alignof.pass.cpp libcxx/test/libcxx-03/libcpp_freestanding.sh.cpp libcxx/test/libcxx-03/localization/locale.categories/__scan_keyword.pass.cpp libcxx/test/libcxx-03/localization/locales/locale.abort.pass.cpp libcxx/test/libcxx-03/localization/locales/locale.category.abort.pass.cpp libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.facet/no_allocation.pass.cpp libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.id/id.pass.cpp libcxx/test/libcxx-03/localization/locales/use_facet.abort.pass.cpp libcxx/test/libcxx-03/memory/allocation_guard.pass.cpp libcxx/test/libcxx-03/memory/allocator_void.trivial.compile.pass.cpp libcxx/test/libcxx-03/memory/allocator_volatile.verify.cpp libcxx/test/libcxx-03/memory/is_allocator.pass.cpp libcxx/test/libcxx-03/memory/swap_allocator.pass.cpp libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_arg.pass.cpp libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_ret.pass.cpp libcxx/test/libcxx-03/memory/trivial_abi/weak_ptr_ret.pass.cpp libcxx/test/libcxx-03/memory/uninitialized_allocator_copy.pass.cpp libcxx/test/libcxx-03/numerics/bit.ops.pass.cpp libcxx/test/libcxx-03/numerics/clamp_to_integral.pass.cpp libcxx/test/libcxx-03/numerics/complex.number/__sqr.pass.cpp libcxx/test/libcxx-03/numerics/complex.number/cmplx.over.pow.pass.cpp libcxx/test/libcxx-03/numerics/numarray/class.gslice.array/get.pass.cpp libcxx/test/libcxx-03/numerics/numarray/class.indirect.array/get.pass.cpp libcxx/test/libcxx-03/numerics/numarray/class.mask.array/get.pass.cpp libcxx/test/libcxx-03/numerics/numarray/class.slice.array/get.pass.cpp libcxx/test/libcxx-03/numerics/rand/rand.device/has-no-random-device.verify.cpp libcxx/test/libcxx-03/strings/basic.string/sizeof.compile.pass.cpp libcxx/test/libcxx-03/strings/basic.string/string.capacity/allocation_size.pass.cpp libcxx/test/libcxx-03/strings/basic.string/string.capacity/max_size.pass.cpp libcxx/test/libcxx-03/strings/basic.string/string.cons/copy_shrunk_long.pass.cpp libcxx/test/libcxx-03/strings/basic.string/string.modifiers/resize_default_initialized.pass.cpp libcxx/test/libcxx-03/strings/c.strings/constexpr_memmove.pass.cpp libcxx/test/libcxx-03/strings/string.view/string.view.iterators/assert.iterator-indexing.pass.cpp libcxx/test/libcxx-03/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/types.pass.cpp libcxx/test/libcxx-03/type_traits/convert_to_integral.pass.cpp libcxx/test/libcxx-03/type_traits/datasizeof.compile.pass.cpp libcxx/test/libcxx-03/type_traits/desugars_to.compile.pass.cpp libcxx/test/libcxx-03/type_traits/is_callable.compile.pass.cpp libcxx/test/libcxx-03/type_traits/is_constant_evaluated.pass.cpp libcxx/test/libcxx-03/type_traits/is_replaceable.compile.pass.cpp libcxx/test/libcxx-03/type_traits/is_trivially_comparable.compile.pass.cpp libcxx/test/libcxx-03/type_traits/is_trivially_relocatable.compile.pass.cpp libcxx/test/libcxx-03/utilities/exception_guard.odr.sh.cpp libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_7.pass.cpp libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke.pass.cpp libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke_helpers.h libcxx/test/libcxx-03/utilities/function.objects/refwrap/desugars_to.compile.pass.cpp libcxx/test/libcxx-03/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp libcxx/test/libcxx-03/utilities/function.objects/unord.hash/murmur2_or_cityhash_ubsan_unsigned_overflow_ignored.pass.cpp libcxx/test/libcxx-03/utilities/is_pointer_in_range.pass.cpp libcxx/test/libcxx-03/utilities/is_valid_range.pass.cpp libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address.pass.cpp libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_funcptr.verify.cpp libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_function.verify.cpp libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp libcxx/test/libcxx-03/utilities/meta/is_referenceable.compile.pass.cpp libcxx/test/libcxx-03/utilities/meta/meta_base.pass.cpp libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.trivial_copy_move.pass.cpp libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.trivially_copyable.compile.pass.cpp libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/pair.incomplete.compile.pass.cpp libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/pair.tuple_element.verify.cpp libcxx/test/libcxx-03/utilities/utility/private_constructor_tag.compile.pass.cpp libcxx/test/libcxx-03/vendor/apple/availability-with-pedantic-errors.compile.pass.cpp libcxx/test/libcxx-03/vendor/apple/disable-availability.sh.cpp libcxx/test/libcxx-03/vendor/apple/system-install-properties.sh.cpp libcxx/test/libcxx-03/vendor/clang-cl/static-lib-exports.sh.cpp libcxx/test/libcxx-03/vendor/mingw/static-lib-exports.sh.cpp View the diff from clang-format here.diff --git a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
index 4e51014f2..205fb1919 100644
--- a/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
+++ b/libcxx/test/libcxx-03/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle.cxx1z.pass.cpp
@@ -31,21 +31,15 @@
#include "test_macros.h"
-struct gen
-{
- std::ptrdiff_t operator()(std::ptrdiff_t n)
- {
- return n-1;
- }
+struct gen {
+ std::ptrdiff_t operator()(std::ptrdiff_t n) { return n - 1; }
};
-
-int main(int, char**)
-{
- std::vector<int> v;
- std::random_shuffle(v.begin(), v.end());
- gen r;
- std::random_shuffle(v.begin(), v.end(), r);
+int main(int, char**) {
+ std::vector<int> v;
+ std::random_shuffle(v.begin(), v.end());
+ gen r;
+ std::random_shuffle(v.begin(), v.end(), r);
return 0;
}
diff --git a/libcxx/test/libcxx-03/algorithms/bad_iterator_traits.verify.cpp b/libcxx/test/libcxx-03/algorithms/bad_iterator_traits.verify.cpp
index a0b5b88bb..974bcd6d1 100644
--- a/libcxx/test/libcxx-03/algorithms/bad_iterator_traits.verify.cpp
+++ b/libcxx/test/libcxx-03/algorithms/bad_iterator_traits.verify.cpp
@@ -17,18 +17,18 @@ struct BadIter {
struct Value {
friend bool operator==(const Value& x, const Value& y);
friend bool operator!=(const Value& x, const Value& y);
- friend bool operator< (const Value& x, const Value& y);
+ friend bool operator<(const Value& x, const Value& y);
friend bool operator<=(const Value& x, const Value& y);
- friend bool operator> (const Value& x, const Value& y);
+ friend bool operator>(const Value& x, const Value& y);
friend bool operator>=(const Value& x, const Value& y);
friend void swap(Value, Value);
};
using iterator_category = std::random_access_iterator_tag;
- using value_type = Value;
- using reference = Value&;
- using difference_type = long;
- using pointer = Value*;
+ using value_type = Value;
+ using reference = Value&;
+ using difference_type = long;
+ using pointer = Value*;
Value operator*() const; // Not `Value&`.
reference operator[](difference_type n) const;
@@ -47,9 +47,9 @@ struct BadIter {
friend bool operator==(const BadIter& x, const BadIter& y);
friend bool operator!=(const BadIter& x, const BadIter& y);
- friend bool operator< (const BadIter& x, const BadIter& y);
+ friend bool operator<(const BadIter& x, const BadIter& y);
friend bool operator<=(const BadIter& x, const BadIter& y);
- friend bool operator> (const BadIter& x, const BadIter& y);
+ friend bool operator>(const BadIter& x, const BadIter& y);
friend bool operator>=(const BadIter& x, const BadIter& y);
};
diff --git a/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp b/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp
index 88a18e859..21da05caa 100644
--- a/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp
+++ b/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp
@@ -25,34 +25,33 @@ namespace {
template <class IntType, class UnderlyingType = IntType>
TEST_CONSTEXPR bool test(IntType max_v = IntType(std::numeric_limits<UnderlyingType>::max())) {
- return std::__half_positive(max_v) == max_v / 2;
+ return std::__half_positive(max_v) == max_v / 2;
}
-} // namespace
+} // namespace
-int main(int, char**)
-{
- {
- assert(test<char>());
- assert(test<int>());
- assert(test<long>());
- assert((test<UserDefinedIntegral<int>, int>()));
- assert(test<std::size_t>());
+int main(int, char**) {
+ {
+ assert(test<char>());
+ assert(test<int>());
+ assert(test<long>());
+ assert((test<UserDefinedIntegral<int>, int>()));
+ assert(test<std::size_t>());
#if !defined(TEST_HAS_NO_INT128)
- assert(test<__int128_t>());
+ assert(test<__int128_t>());
#endif // !defined(TEST_HAS_NO_INT128)
- }
+ }
#if TEST_STD_VER >= 11
- {
- static_assert(test<char>(), "");
- static_assert(test<int>(), "");
- static_assert(test<long>(), "");
- static_assert(test<std::size_t>(), "");
-#if !defined(TEST_HAS_NO_INT128)
- static_assert(test<__int128_t>(), "");
-#endif // !defined(TEST_HAS_NO_INT128)
- }
+ {
+ static_assert(test<char>(), "");
+ static_assert(test<int>(), "");
+ static_assert(test<long>(), "");
+ static_assert(test<std::size_t>(), "");
+# if !defined(TEST_HAS_NO_INT128)
+ static_assert(test<__int128_t>(), "");
+# endif // !defined(TEST_HAS_NO_INT128)
+ }
#endif // TEST_STD_VER >= 11
return 0;
diff --git a/libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp b/libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp
index 03fef57ee..eb7209f13 100644
--- a/libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp
+++ b/libcxx/test/libcxx-03/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp
@@ -19,12 +19,12 @@
template <class Sub, class Iterator>
struct IteratorAdaptorBase {
- using OutTraits = std::iterator_traits<Iterator>;
+ using OutTraits = std::iterator_traits<Iterator>;
using iterator_category = typename OutTraits::iterator_category;
- using value_type = typename OutTraits::value_type;
- using pointer = typename OutTraits::pointer;
- using reference = typename OutTraits::reference;
- using difference_type = typename OutTraits::difference_type;
+ using value_type = typename OutTraits::value_type;
+ using pointer = typename OutTraits::pointer;
+ using reference = typename OutTraits::reference;
+ using difference_type = typename OutTraits::difference_type;
IteratorAdaptorBase() {}
IteratorAdaptorBase(Iterator) {}
@@ -61,13 +61,12 @@ struct IteratorAdaptorBase {
friend bool operator<=(Sub, Sub) { return false; }
friend bool operator>=(Sub, Sub) { return false; }
- private:
+private:
Iterator it_;
};
template <typename It>
-struct Cpp20HostileIterator
- : IteratorAdaptorBase<Cpp20HostileIterator<It>, It> {
+struct Cpp20HostileIterator : IteratorAdaptorBase<Cpp20HostileIterator<It>, It> {
Cpp20HostileIterator() {}
Cpp20HostileIterator(It) {}
};
@@ -83,143 +82,143 @@ void test() {
Pred pred;
std::mt19937_64 rng;
- (void) std::adjacent_find(it, it);
- (void) std::adjacent_find(it, it, pred);
- (void) std::all_of(it, it, pred);
- (void) std::any_of(it, it, pred);
- (void) std::binary_search(it, it, 0);
- (void) std::binary_search(it, it, 0, pred);
- (void) std::copy_backward(it, it, it);
- (void) std::copy_if(it, it, it, pred);
- (void) std::copy_n(it, 0, it);
- (void) std::copy(it, it, it);
- (void) std::count_if(it, it, pred);
- (void) std::count(it, it, 0);
- (void) std::equal_range(it, it, 0);
- (void) std::equal_range(it, it, 0, pred);
- (void) std::equal(it, it, it);
- (void) std::equal(it, it, it, pred);
+ (void)std::adjacent_find(it, it);
+ (void)std::adjacent_find(it, it, pred);
+ (void)std::all_of(it, it, pred);
+ (void)std::any_of(it, it, pred);
+ (void)std::binary_search(it, it, 0);
+ (void)std::binary_search(it, it, 0, pred);
+ (void)std::copy_backward(it, it, it);
+ (void)std::copy_if(it, it, it, pred);
+ (void)std::copy_n(it, 0, it);
+ (void)std::copy(it, it, it);
+ (void)std::count_if(it, it, pred);
+ (void)std::count(it, it, 0);
+ (void)std::equal_range(it, it, 0);
+ (void)std::equal_range(it, it, 0, pred);
+ (void)std::equal(it, it, it);
+ (void)std::equal(it, it, it, pred);
#if TEST_STD_VER > 11
- (void) std::equal(it, it, it, it);
- (void) std::equal(it, it, it, it, pred);
+ (void)std::equal(it, it, it, it);
+ (void)std::equal(it, it, it, it, pred);
#endif
- (void) std::fill_n(it, 0, 0);
- (void) std::fill(it, it, 0);
- (void) std::find_end(it, it, it, it);
- (void) std::find_end(it, it, it, it, pred);
- (void) std::find_first_of(it, it, it, it);
- (void) std::find_first_of(it, it, it, it, pred);
- (void) std::find_if_not(it, it, pred);
- (void) std::find_if(it, it, pred);
- (void) std::find(it, it, 0);
+ (void)std::fill_n(it, 0, 0);
+ (void)std::fill(it, it, 0);
+ (void)std::find_end(it, it, it, it);
+ (void)std::find_end(it, it, it, it, pred);
+ (void)std::find_first_of(it, it, it, it);
+ (void)std::find_first_of(it, it, it, it, pred);
+ (void)std::find_if_not(it, it, pred);
+ (void)std::find_if(it, it, pred);
+ (void)std::find(it, it, 0);
#if TEST_STD_VER > 14
- (void) std::for_each_n(it, 0, pred);
+ (void)std::for_each_n(it, 0, pred);
#endif
- (void) std::for_each(it, it, pred);
- (void) std::generate_n(it, 0, pred);
- (void) std::generate(it, it, pred);
- (void) std::includes(it, it, it, it);
- (void) std::includes(it, it, it, it, pred);
- (void) std::inplace_merge(it, it, it);
- (void) std::inplace_merge(it, it, it, pred);
- (void) std::is_heap_until(it, it);
- (void) std::is_heap_until(it, it, pred);
- (void) std::is_heap(it, it);
- (void) std::is_heap(it, it, pred);
- (void) std::is_partitioned(it, it, pred);
- (void) std::is_permutation(it, it, it);
- (void) std::is_permutation(it, it, it, pred);
+ (void)std::for_each(it, it, pred);
+ (void)std::generate_n(it, 0, pred);
+ (void)std::generate(it, it, pred);
+ (void)std::includes(it, it, it, it);
+ (void)std::includes(it, it, it, it, pred);
+ (void)std::inplace_merge(it, it, it);
+ (void)std::inplace_merge(it, it, it, pred);
+ (void)std::is_heap_until(it, it);
+ (void)std::is_heap_until(it, it, pred);
+ (void)std::is_heap(it, it);
+ (void)std::is_heap(it, it, pred);
+ (void)std::is_partitioned(it, it, pred);
+ (void)std::is_permutation(it, it, it);
+ (void)std::is_permutation(it, it, it, pred);
#if TEST_STD_VER > 11
- (void) std::is_permutation(it, it, it, it);
- (void) std::is_permutation(it, it, it, it, pred);
+ (void)std::is_permutation(it, it, it, it);
+ (void)std::is_permutation(it, it, it, it, pred);
#endif
- (void) std::is_sorted_until(it, it);
- (void) std::is_sorted_until(it, it, pred);
- (void) std::is_sorted(it, it);
- (void) std::is_sorted(it, it, pred);
- (void) std::lexicographical_compare(it, it, it, it);
- (void) std::lexicographical_compare(it, it, it, it, pred);
+ (void)std::is_sorted_until(it, it);
+ (void)std::is_sorted_until(it, it, pred);
+ (void)std::is_sorted(it, it);
+ (void)std::is_sorted(it, it, pred);
+ (void)std::lexicographical_compare(it, it, it, it);
+ (void)std::lexicographical_compare(it, it, it, it, pred);
#if TEST_STD_VER > 17
(void)std::lexicographical_compare_three_way(it, it, it, it);
(void)std::lexicographical_compare_three_way(it, it, it, it, std::compare_three_way());
#endif
- (void) std::lower_bound(it, it, 0);
- (void) std::lower_bound(it, it, 0, pred);
- (void) std::make_heap(it, it);
- (void) std::make_heap(it, it, pred);
- (void) std::max_element(it, it);
- (void) std::max_element(it, it, pred);
- (void) std::merge(it, it, it, it, it);
- (void) std::merge(it, it, it, it, it, pred);
- (void) std::min_element(it, it);
- (void) std::min_element(it, it, pred);
- (void) std::minmax_element(it, it);
- (void) std::minmax_element(it, it, pred);
- (void) std::mismatch(it, it, it);
- (void) std::mismatch(it, it, it, pred);
- (void) std::move_backward(it, it, it);
- (void) std::move(it, it, it);
- (void) std::next_permutation(it, it);
- (void) std::next_permutation(it, it, pred);
- (void) std::none_of(it, it, pred);
- (void) std::nth_element(it, it, it);
- (void) std::nth_element(it, it, it, pred);
- (void) std::partial_sort_copy(it, it, it, it);
- (void) std::partial_sort_copy(it, it, it, it, pred);
- (void) std::partial_sort(it, it, it);
- (void) std::partial_sort(it, it, it, pred);
- (void) std::partition_copy(it, it, it, it, pred);
- (void) std::partition_point(it, it, pred);
- (void) std::partition(it, it, pred);
- (void) std::pop_heap(it, it);
- (void) std::pop_heap(it, it, pred);
- (void) std::prev_permutation(it, it);
- (void) std::prev_permutation(it, it, pred);
- (void) std::push_heap(it, it);
- (void) std::push_heap(it, it, pred);
- (void) std::remove_copy_if(it, it, it, pred);
- (void) std::remove_copy(it, it, it, 0);
- (void) std::remove_if(it, it, pred);
- (void) std::remove(it, it, 0);
- (void) std::replace_copy_if(it, it, it, pred, 0);
- (void) std::replace_copy(it, it, it, 0, 0);
- (void) std::replace_if(it, it, pred, 0);
- (void) std::replace(it, it, 0, 0);
- (void) std::reverse_copy(it, it, it);
- (void) std::reverse(it, it);
- (void) std::rotate_copy(it, it, it, it);
- (void) std::rotate(it, it, it);
+ (void)std::lower_bound(it, it, 0);
+ (void)std::lower_bound(it, it, 0, pred);
+ (void)std::make_heap(it, it);
+ (void)std::make_heap(it, it, pred);
+ (void)std::max_element(it, it);
+ (void)std::max_element(it, it, pred);
+ (void)std::merge(it, it, it, it, it);
+ (void)std::merge(it, it, it, it, it, pred);
+ (void)std::min_element(it, it);
+ (void)std::min_element(it, it, pred);
+ (void)std::minmax_element(it, it);
+ (void)std::minmax_element(it, it, pred);
+ (void)std::mismatch(it, it, it);
+ (void)std::mismatch(it, it, it, pred);
+ (void)std::move_backward(it, it, it);
+ (void)std::move(it, it, it);
+ (void)std::next_permutation(it, it);
+ (void)std::next_permutation(it, it, pred);
+ (void)std::none_of(it, it, pred);
+ (void)std::nth_element(it, it, it);
+ (void)std::nth_element(it, it, it, pred);
+ (void)std::partial_sort_copy(it, it, it, it);
+ (void)std::partial_sort_copy(it, it, it, it, pred);
+ (void)std::partial_sort(it, it, it);
+ (void)std::partial_sort(it, it, it, pred);
+ (void)std::partition_copy(it, it, it, it, pred);
+ (void)std::partition_point(it, it, pred);
+ (void)std::partition(it, it, pred);
+ (void)std::pop_heap(it, it);
+ (void)std::pop_heap(it, it, pred);
+ (void)std::prev_permutation(it, it);
+ (void)std::prev_permutation(it, it, pred);
+ (void)std::push_heap(it, it);
+ (void)std::push_heap(it, it, pred);
+ (void)std::remove_copy_if(it, it, it, pred);
+ (void)std::remove_copy(it, it, it, 0);
+ (void)std::remove_if(it, it, pred);
+ (void)std::remove(it, it, 0);
+ (void)std::replace_copy_if(it, it, it, pred, 0);
+ (void)std::replace_copy(it, it, it, 0, 0);
+ (void)std::replace_if(it, it, pred, 0);
+ (void)std::replace(it, it, 0, 0);
+ (void)std::reverse_copy(it, it, it);
+ (void)std::reverse(it, it);
+ (void)std::rotate_copy(it, it, it, it);
+ (void)std::rotate(it, it, it);
#if TEST_STD_VER > 14
- (void) std::sample(it, it, it, 0, rng);
+ (void)std::sample(it, it, it, 0, rng);
#endif
- (void) std::search(it, it, it, it);
- (void) std::search(it, it, it, it, pred);
+ (void)std::search(it, it, it, it);
+ (void)std::search(it, it, it, it, pred);
#if TEST_STD_VER > 14
- (void) std::search(it, it, std::default_searcher<Cpp20HostileIterator<int*>>(it, it));
+ (void)std::search(it, it, std::default_searcher<Cpp20HostileIterator<int*>>(it, it));
#endif
- (void) std::set_difference(it, it, it, it, it);
- (void) std::set_difference(it, it, it, it, it, pred);
- (void) std::set_intersection(it, it, it, it, it);
- (void) std::set_intersection(it, it, it, it, it, pred);
- (void) std::set_symmetric_difference(it, it, it, it, it);
- (void) std::set_symmetric_difference(it, it, it, it, it, pred);
- (void) std::set_union(it, it, it, it, it);
- (void) std::set_union(it, it, it, it, it, pred);
+ (void)std::set_difference(it, it, it, it, it);
+ (void)std::set_difference(it, it, it, it, it, pred);
+ (void)std::set_intersection(it, it, it, it, it);
+ (void)std::set_intersection(it, it, it, it, it, pred);
+ (void)std::set_symmetric_difference(it, it, it, it, it);
+ (void)std::set_symmetric_difference(it, it, it, it, it, pred);
+ (void)std::set_union(it, it, it, it, it);
+ (void)std::set_union(it, it, it, it, it, pred);
#if TEST_STD_VER > 17
- (void) std::shift_left(it, it, 0);
- (void) std::shift_right(it, it, 0);
+ (void)std::shift_left(it, it, 0);
+ (void)std::shift_right(it, it, 0);
#endif
- (void) std::shuffle(it, it, rng);
- (void) std::sort_heap(it, it);
- (void) std::sort_heap(it, it, pred);
- (void) std::sort(it, it);
- (void) std::sort(it, it, pred);
- (void) std::stable_partition(it, it, pred);
- (void) std::stable_sort(it, it);
- (void) std::swap_ranges(it, it, it);
- (void) std::transform(it, it, it, pred);
- (void) std::transform(it, it, it, it, pred);
- (void) std::unique_copy(it, it, it);
- (void) std::unique(it, it);
- (void) std::upper_bound(it, it, 0);
+ (void)std::shuffle(it, it, rng);
+ (void)std::sort_heap(it, it);
+ (void)std::sort_heap(it, it, pred);
+ (void)std::sort(it, it);
+ (void)std::sort(it, it, pred);
+ (void)std::stable_partition(it, it, pred);
+ (void)std::stable_sort(it, it);
+ (void)std::swap_ranges(it, it, it);
+ (void)std::transform(it, it, it, pred);
+ (void)std::transform(it, it, it, it, pred);
+ (void)std::unique_copy(it, it, it);
+ (void)std::unique(it, it);
+ (void)std::upper_bound(it, it, 0);
}
diff --git a/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp b/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp
index 69154c3f7..688715eee 100644
--- a/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp
+++ b/libcxx/test/libcxx-03/assertions/customize_verbose_abort.compile-time.pass.cpp
@@ -17,9 +17,7 @@
#include <cstdlib>
-void my_abort(char const*, ...) {
- std::exit(EXIT_SUCCESS);
-}
+void my_abort(char const*, ...) { std::exit(EXIT_SUCCESS); }
int main(int, char**) {
_LIBCPP_VERBOSE_ABORT("%s", "message");
diff --git a/libcxx/test/libcxx-03/atomics/atomics.order/memory_order.underlying_type.pass.cpp b/libcxx/test/libcxx-03/atomics/atomics.order/memory_order.underlying_type.pass.cpp
index 5379ef878..7977b1891 100644
--- a/libcxx/test/libcxx-03/atomics/atomics.order/memory_order.underlying_type.pass.cpp
+++ b/libcxx/test/libcxx-03/atomics/atomics.order/memory_order.underlying_type.pass.cpp
@@ -18,17 +18,18 @@
#include "test_macros.h"
-
enum cpp17_memory_order {
- cpp17_memory_order_relaxed, cpp17_memory_order_consume, cpp17_memory_order_acquire,
- cpp17_memory_order_release, cpp17_memory_order_acq_rel, cpp17_memory_order_seq_cst
+ cpp17_memory_order_relaxed,
+ cpp17_memory_order_consume,
+ cpp17_memory_order_acquire,
+ cpp17_memory_order_release,
+ cpp17_memory_order_acq_rel,
+ cpp17_memory_order_seq_cst
};
static_assert((std::is_same<std::underlying_type<cpp17_memory_order>::type,
std::underlying_type<std::memory_order>::type>::value),
- "std::memory_order should have the same underlying type as a corresponding "
- "unscoped enumeration would. Otherwise, our ABI changes from C++17 to C++20.");
+ "std::memory_order should have the same underlying type as a corresponding "
+ "unscoped enumeration would. Otherwise, our ABI changes from C++17 to C++20.");
-int main(int, char**) {
- return 0;
-}
+int main(int, char**) { return 0; }
diff --git a/libcxx/test/libcxx-03/atomics/diagnose_invalid_memory_order.verify.cpp b/libcxx/test/libcxx-03/atomics/diagnose_invalid_memory_order.verify.cpp
index 1b0b945f3..f390b84ba 100644
--- a/libcxx/test/libcxx-03/atomics/diagnose_invalid_memory_order.verify.cpp
+++ b/libcxx/test/libcxx-03/atomics/diagnose_invalid_memory_order.verify.cpp
@@ -15,108 +15,201 @@
#include <atomic>
void f() {
- std::atomic<int> x(42);
- volatile std::atomic<int>& vx = x;
- int val1 = 1; ((void)val1);
- int val2 = 2; ((void)val2);
- // load operations
- {
- x.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- x.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- vx.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- vx.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- // valid memory orders
- x.load(std::memory_order_relaxed);
- x.load(std::memory_order_consume);
- x.load(std::memory_order_acquire);
- x.load(std::memory_order_seq_cst);
- }
- {
- std::atomic_load_explicit(&x, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_load_explicit(&x, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_load_explicit(&vx, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_load_explicit(&vx, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- // valid memory orders
- std::atomic_load_explicit(&x, std::memory_order_relaxed);
- std::atomic_load_explicit(&x, std::memory_order_consume);
- std::atomic_load_explicit(&x, std::memory_order_acquire);
- std::atomic_load_explicit(&x, std::memory_order_seq_cst);
- }
- // store operations
- {
- x.store(42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
- x.store(42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
- x.store(42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- vx.store(42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
- vx.store(42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
- vx.store(42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- // valid memory orders
- x.store(42, std::memory_order_relaxed);
- x.store(42, std::memory_order_release);
- x.store(42, std::memory_order_seq_cst);
- }
- {
- std::atomic_store_explicit(&x, 42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_store_explicit(&x, 42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_store_explicit(&x, 42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_store_explicit(&vx, 42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_store_explicit(&vx, 42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_store_explicit(&vx, 42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- // valid memory orders
- std::atomic_store_explicit(&x, 42, std::memory_order_relaxed);
- std::atomic_store_explicit(&x, 42, std::memory_order_release);
- std::atomic_store_explicit(&x, 42, std::memory_order_seq_cst);
- }
- // compare exchange weak
- {
- x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- vx.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- vx.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- // valid memory orders
- x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
- x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
- x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
- x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
- // Test that the cmpxchg overload with only one memory order argument
- // does not generate any diagnostics.
- x.compare_exchange_weak(val1, val2, std::memory_order_release);
- }
- {
- std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_compare_exchange_weak_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_compare_exchange_weak_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- // valid memory orders
- std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
- std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
- std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
- std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
- }
- // compare exchange strong
- {
- x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- vx.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- vx.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- // valid memory orders
- x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
- x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
- x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
- x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
- // Test that the cmpxchg overload with only one memory order argument
- // does not generate any diagnostics.
- x.compare_exchange_strong(val1, val2, std::memory_order_release);
- }
- {
- std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_compare_exchange_strong_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
- std::atomic_compare_exchange_strong_explicit(&vx, &val1, val2, std::memory_order_seq_cst, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
- // valid memory orders
- std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
- std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
- std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
- std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
- }
+ std::atomic<int> x(42);
+ volatile std::atomic<int>& vx = x;
+ int val1 = 1;
+ ((void)val1);
+ int val2 = 2;
+ ((void)val2);
+ // load operations
+ {
+ x.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ x.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ vx.load(std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ vx.load(std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ // valid memory orders
+ x.load(std::memory_order_relaxed);
+ x.load(std::memory_order_consume);
+ x.load(std::memory_order_acquire);
+ x.load(std::memory_order_seq_cst);
+ }
+ {
+ std::atomic_load_explicit(
+ &x, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_load_explicit(
+ &x, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_load_explicit(
+ &vx, std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_load_explicit(
+ &vx, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ // valid memory orders
+ std::atomic_load_explicit(&x, std::memory_order_relaxed);
+ std::atomic_load_explicit(&x, std::memory_order_consume);
+ std::atomic_load_explicit(&x, std::memory_order_acquire);
+ std::atomic_load_explicit(&x, std::memory_order_seq_cst);
+ }
+ // store operations
+ {
+ x.store(42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
+ x.store(42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
+ x.store(42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ vx.store(42,
+ std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
+ vx.store(42,
+ std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
+ vx.store(42,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ // valid memory orders
+ x.store(42, std::memory_order_relaxed);
+ x.store(42, std::memory_order_release);
+ x.store(42, std::memory_order_seq_cst);
+ }
+ {
+ std::atomic_store_explicit(
+ &x, 42, std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_store_explicit(
+ &x, 42, std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_store_explicit(
+ &x, 42, std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_store_explicit(
+ &vx,
+ 42,
+ std::memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_store_explicit(
+ &vx,
+ 42,
+ std::memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_store_explicit(
+ &vx,
+ 42,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ // valid memory orders
+ std::atomic_store_explicit(&x, 42, std::memory_order_relaxed);
+ std::atomic_store_explicit(&x, 42, std::memory_order_release);
+ std::atomic_store_explicit(&x, 42, std::memory_order_seq_cst);
+ }
+ // compare exchange weak
+ {
+ x.compare_exchange_weak(
+ val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ x.compare_exchange_weak(
+ val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ vx.compare_exchange_weak(
+ val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ vx.compare_exchange_weak(
+ val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ // valid memory orders
+ x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
+ x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
+ x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
+ x.compare_exchange_weak(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
+ // Test that the cmpxchg overload with only one memory order argument
+ // does not generate any diagnostics.
+ x.compare_exchange_weak(val1, val2, std::memory_order_release);
+ }
+ {
+ std::atomic_compare_exchange_weak_explicit(
+ &x,
+ &val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_compare_exchange_weak_explicit(
+ &x,
+ &val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_compare_exchange_weak_explicit(
+ &vx,
+ &val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_compare_exchange_weak_explicit(
+ &vx,
+ &val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ // valid memory orders
+ std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
+ std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
+ std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
+ std::atomic_compare_exchange_weak_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
+ }
+ // compare exchange strong
+ {
+ x.compare_exchange_strong(
+ val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ x.compare_exchange_strong(
+ val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ vx.compare_exchange_strong(
+ val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ vx.compare_exchange_strong(
+ val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ // valid memory orders
+ x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
+ x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
+ x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
+ x.compare_exchange_strong(val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
+ // Test that the cmpxchg overload with only one memory order argument
+ // does not generate any diagnostics.
+ x.compare_exchange_strong(val1, val2, std::memory_order_release);
+ }
+ {
+ std::atomic_compare_exchange_strong_explicit(
+ &x,
+ &val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_compare_exchange_strong_explicit(
+ &x,
+ &val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_compare_exchange_strong_explicit(
+ &vx,
+ &val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
+ std::atomic_compare_exchange_strong_explicit(
+ &vx,
+ &val1,
+ val2,
+ std::memory_order_seq_cst,
+ std::memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
+ // valid memory orders
+ std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_relaxed);
+ std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_consume);
+ std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_acquire);
+ std::atomic_compare_exchange_strong_explicit(&x, &val1, val2, std::memory_order_seq_cst, std::memory_order_seq_cst);
+ }
}
diff --git a/libcxx/test/libcxx-03/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp b/libcxx/test/libcxx-03/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp
index cad0bd8b3..25488db75 100644
--- a/libcxx/test/libcxx-03/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp
+++ b/libcxx/test/libcxx-03/depr/depr.auto.ptr/auto.ptr/auto_ptr.cxx1z.pass.cpp
@@ -23,9 +23,8 @@
#include "test_macros.h"
-int main(int, char**)
-{
- std::auto_ptr<int> p;
+int main(int, char**) {
+ std::auto_ptr<int> p;
return 0;
}
diff --git a/libcxx/test/libcxx-03/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp b/libcxx/test/libcxx-03/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp
index d212f36bb..6a848ed69 100644
--- a/libcxx/test/libcxx-03/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp
+++ b/libcxx/test/libcxx-03/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp
@@ -8,7 +8,6 @@
// <functional>
-
// In C++17, the function adapters mem_fun/mem_fun_ref, etc have been removed.
// However, for backwards compatibility, if _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
// is defined before including <functional>, then they will be restored.
@@ -33,36 +32,28 @@ struct Foo {
int sum(int a, int b) const { return a + b; }
};
-int main(int, char**)
-{
- typedef std::pointer_to_unary_function<int, int> PUF;
- typedef std::pointer_to_binary_function<int, int, int> PBF;
+int main(int, char**) {
+ typedef std::pointer_to_unary_function<int, int> PUF;
+ typedef std::pointer_to_binary_function<int, int, int> PBF;
- static_assert(
- (std::is_same<PUF, decltype((std::ptr_fun<int, int>(identity)))>::value),
- "");
- static_assert(
- (std::is_same<PBF, decltype((std::ptr_fun<int, int, int>(sum)))>::value),
- "");
+ static_assert((std::is_same<PUF, decltype((std::ptr_fun<int, int>(identity)))>::value), "");
+ static_assert((std::is_same<PBF, decltype((std::ptr_fun<int, int, int>(sum)))>::value), "");
- assert((std::ptr_fun<int, int>(identity)(4) == 4));
- assert((std::ptr_fun<int, int, int>(sum)(4, 5) == 9));
+ assert((std::ptr_fun<int, int>(identity)(4) == 4));
+ assert((std::ptr_fun<int, int, int>(sum)(4, 5) == 9));
- Foo f;
- assert((std::mem_fn(&Foo::identity)(f, 5) == 5));
- assert((std::mem_fn(&Foo::sum)(f, 5, 6) == 11));
+ Foo f;
+ assert((std::mem_fn(&Foo::identity)(f, 5) == 5));
+ assert((std::mem_fn(&Foo::sum)(f, 5, 6) == 11));
- typedef std::mem_fun_ref_t<int, Foo> MFR;
- typedef std::const_mem_fun_ref_t<int, Foo> CMFR;
+ typedef std::mem_fun_ref_t<int, Foo> MFR;
+ typedef std::const_mem_fun_ref_t<int, Foo> CMFR;
- static_assert(
- (std::is_same<MFR, decltype((std::mem_fun_ref(&Foo::zero)))>::value), "");
- static_assert((std::is_same<CMFR, decltype((std::mem_fun_ref(
- &Foo::zero_const)))>::value),
- "");
+ static_assert((std::is_same<MFR, decltype((std::mem_fun_ref(&Foo::zero)))>::value), "");
+ static_assert((std::is_same<CMFR, decltype((std::mem_fun_ref(&Foo::zero_const)))>::value), "");
- assert((std::mem_fun_ref(&Foo::zero)(f) == 0));
- assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5));
+ assert((std::mem_fun_ref(&Foo::zero)(f) == 0));
+ assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5));
return 0;
}
diff --git a/libcxx/test/libcxx-03/depr/exception.unexpected/get_unexpected.pass.cpp b/libcxx/test/libcxx-03/depr/exception.unexpected/get_unexpected.pass.cpp
index e4533a01c..668839deb 100644
--- a/libcxx/test/libcxx-03/depr/exception.unexpected/get_unexpected.pass.cpp
+++ b/libcxx/test/libcxx-03/depr/exception.unexpected/get_unexpected.pass.cpp
@@ -19,26 +19,21 @@
void f1() {}
void f2() {}
-void f3()
-{
- std::exit(0);
-}
-
-int main(int, char**)
-{
-
- std::unexpected_handler old = std::get_unexpected();
- // verify there is a previous unexpected handler
- assert(old);
- std::set_unexpected(f1);
- assert(std::get_unexpected() == f1);
- // verify f1 was replace with f2
- std::set_unexpected(f2);
- assert(std::get_unexpected() == f2);
- // verify calling original unexpected handler calls terminate
- std::set_terminate(f3);
- (*old)();
- assert(0);
+void f3() { std::exit(0); }
+
+int main(int, char**) {
+ std::unexpected_handler old = std::get_unexpected();
+ // verify there is a previous unexpected handler
+ assert(old);
+ std::set_unexpected(f1);
+ assert(std::get_unexpected() == f1);
+ // verify f1 was replace with f2
+ std::set_unexpected(f2);
+ assert(std::get_unexpected() == f2);
+ // verify calling original unexpected handler calls terminate
+ std::set_terminate(f3);
+ (*old)();
+ assert(0);
return 0;
}
diff --git a/libcxx/test/libcxx-03/depr/exception.unexpected/set_unexpected.pass.cpp b/libcxx/test/libcxx-03/depr/exception.unexpected/set_unexpected.pass.cpp
index f428790f6..c687cb752 100644
--- a/libcxx/test/libcxx-03/depr/exception.unexpected/set_unexpected.pass.cpp
+++ b/libcxx/test/libcxx-03/depr/exception.unexpected/set_unexpected.pass.cpp
@@ -19,22 +19,18 @@
void f1() {}
void f2() {}
-void f3()
-{
- std::exit(0);
-}
-
-int main(int, char**)
-{
- std::unexpected_handler old = std::set_unexpected(f1);
- // verify there is a previous unexpected handler
- assert(old);
- // verify f1 was replace with f2
- assert(std::set_unexpected(f2) == f1);
- // verify calling original unexpected handler calls terminate
- std::set_terminate(f3);
- (*old)();
- assert(0);
+void f3() { std::exit(0); }
+
+int main(int, char**) {
+ std::unexpected_handler old = std::set_unexpected(f1);
+ // verify there is a previous unexpected handler
+ assert(old);
+ // verify f1 was replace with f2
+ assert(std::set_unexpected(f2) == f1);
+ // verify calling original unexpected handler calls terminate
+ std::set_terminate(f3);
+ (*old)();
+ assert(0);
return 0;
}
diff --git a/libcxx/test/libcxx-03/depr/exception.unexpected/unexpected.pass.cpp b/libcxx/test/libcxx-03/depr/exception.unexpected/unexpected.pass.cpp
index 6ab1147b9..3da9e6751 100644
--- a/libcxx/test/libcxx-03/depr/exception.unexpected/unexpected.pass.cpp
+++ b/libcxx/test/libcxx-03/depr/exception.unexpected/unexpected.pass.cpp
@@ -16,16 +16,12 @@
#include "test_macros.h"
-void fexit()
-{
- std::exit(0);
-}
+void fexit() { std::exit(0); }
-int main(int, char**)
-{
- std::set_unexpected(fexit);
- std::unexpected();
- assert(false);
+int main(int, char**) {
+ std::set_unexpected(fexit);
+ std::unexpected();
+ assert(false);
return 0;
}
diff --git a/libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp b/libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp
index d77d5370f..9069a305e 100644
--- a/libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp
+++ b/libcxx/test/libcxx-03/input.output/file.streams/fstreams/fstream.close.pass.cpp
@@ -20,19 +20,18 @@
#include "test_macros.h"
#include "platform_support.h"
-int main(int, char**)
-{
- std::string temp = get_temp_file_name();
+int main(int, char**) {
+ std::string temp = get_temp_file_name();
- std::fstream ofs(temp, std::ios::out | std::ios::trunc);
- ofs << "Hello, World!\n";
- assert( ofs.good());
- ofs.close();
- assert( ofs.good());
- ofs << "Hello, World!\n";
- assert(!ofs.good());
+ std::fstream ofs(temp, std::ios::out | std::ios::trunc);
+ ofs << "Hello, World!\n";
+ assert(ofs.good());
+ ofs.close();
+ assert(ofs.good());
+ ofs << "Hello, World!\n";
+ assert(!ofs.good());
- std::remove(temp.c_str());
+ std::remove(temp.c_str());
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp b/libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp
index a03aed123..af14100b7 100644
--- a/libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp
+++ b/libcxx/test/libcxx-03/input.output/iostream.format/input.streams/traits_mismatch.verify.cpp
@@ -18,8 +18,7 @@
#include <istream>
#include <string>
-struct test_istream
- : public std::basic_istream<char, std::char_traits<wchar_t> > {};
+struct test_istream : public std::basic_istream<char, std::char_traits<wchar_t> > {};
// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error@*:* {{only virtual member functions can be marked 'override'}}
diff --git a/libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp b/libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp
index 9e7bc998e..977add05c 100644
--- a/libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp
+++ b/libcxx/test/libcxx-03/input.output/iostream.format/output.streams/traits_mismatch.verify.cpp
@@ -18,8 +18,7 @@
#include <ostream>
#include <string>
-struct test_ostream
- : public std::basic_ostream<char, std::char_traits<wchar_t> > {};
+struct test_ostream : public std::basic_ostream<char, std::char_traits<wchar_t> > {};
// expected-error-re@*:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
// expected-error@*:* {{only virtual member functions can be marked 'override'}}
diff --git a/libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp b/libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp
index 8f0f5a6d7..ecad8f468 100644
--- a/libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp
+++ b/libcxx/test/libcxx-03/input.output/iostreams.base/ios/iostate.flags/clear.abort.pass.cpp
@@ -24,20 +24,17 @@
#include "test_macros.h"
-
-void exit_success(int) {
- std::_Exit(EXIT_SUCCESS);
-}
+void exit_success(int) { std::_Exit(EXIT_SUCCESS); }
struct testbuf : public std::streambuf {};
int main(int, char**) {
- std::signal(SIGABRT, exit_success);
+ std::signal(SIGABRT, exit_success);
- testbuf buf;
- std::ios ios(&buf);
- ios.exceptions(std::ios::badbit);
- ios.clear(std::ios::badbit);
+ testbuf buf;
+ std::ios ios(&buf);
+ ios.exceptions(std::ios::badbit);
+ ios.clear(std::ios::badbit);
- return EXIT_FAILURE;
+ return EXIT_FAILURE;
}
diff --git a/libcxx/test/libcxx-03/iterators/bounded_iter/pointer_traits.pass.cpp b/libcxx/test/libcxx-03/iterators/bounded_iter/pointer_traits.pass.cpp
index 22ad8c670..2658fe269 100644
--- a/libcxx/test/libcxx-03/iterators/bounded_iter/pointer_traits.pass.cpp
+++ b/libcxx/test/libcxx-03/iterators/bounded_iter/pointer_traits.pass.cpp
@@ -24,12 +24,14 @@
template <class Iter>
TEST_CONSTEXPR_CXX14 bool tests() {
- using BoundedIter = std::__bounded_iter<Iter>;
- using PointerTraits = std::pointer_traits<BoundedIter>;
+ using BoundedIter = std::__bounded_iter<Iter>;
+ using PointerTraits = std::pointer_traits<BoundedIter>;
using BasePointerTraits = std::pointer_traits<Iter>;
static_assert(std::is_same<typename PointerTraits::pointer, BoundedIter>::value, "");
- static_assert(std::is_same<typename PointerTraits::element_type, typename BasePointerTraits::element_type>::value, "");
- static_assert(std::is_same<typename PointerTraits::difference_type, typename BasePointerTraits::difference_type>::value, "");
+ static_assert(
+ std::is_same<typename PointerTraits::element_type, typename BasePointerTraits::element_type>::value, "");
+ static_assert(
+ std::is_same<typename PointerTraits::difference_type, typename BasePointerTraits::difference_type>::value, "");
{
int array[] = {0, 1, 2, 3, 4};
diff --git a/libcxx/test/libcxx-03/iterators/bounded_iter/types.compile.pass.cpp b/libcxx/test/libcxx-03/iterators/bounded_iter/types.compile.pass.cpp
index d205c5b03..9f7f88c64 100644
--- a/libcxx/test/libcxx-03/iterators/bounded_iter/types.compile.pass.cpp
+++ b/libcxx/test/libcxx-03/iterators/bounded_iter/types.compile.pass.cpp
@@ -39,7 +39,6 @@ static_assert(std::is_same<BoundedIter1::iterator_category, Iterator::iterator_c
static_assert(std::is_same<BoundedIter1::iterator_concept, Iterator::iterator_concept>::value, "");
#endif
-
using BoundedIter2 = std::__bounded_iter<int*>;
static_assert(std::is_same<BoundedIter2::value_type, int>::value, "");
static_assert(std::is_same<BoundedIter2::difference_type, std::ptrdiff_t>::value, "");
diff --git a/libcxx/test/libcxx-03/iterators/contiguous_iterators.pass.cpp b/libcxx/test/libcxx-03/iterators/contiguous_iterators.pass.cpp
index f00ca4e87..870d90a44 100644
--- a/libcxx/test/libcxx-03/iterators/contiguous_iterators.pass.cpp
+++ b/libcxx/test/libcxx-03/iterators/contiguous_iterators.pass.cpp
@@ -28,238 +28,240 @@
#include "test_iterators.h"
#if TEST_STD_VER >= 17
-#include <string_view>
+# include <string_view>
#endif
#if TEST_STD_VER >= 20
-#include <span>
+# include <span>
#endif
-class T; // incomplete
+class T; // incomplete
+
+class my_input_iterator {
+ struct tag : std::input_iterator_tag {};
+ typedef my_input_iterator Self;
+ int* state_;
-class my_input_iterator
-{
- struct tag : std::input_iterator_tag {};
- typedef my_input_iterator Self;
- int *state_;
public:
- typedef tag iterator_category;
- typedef int value_type;
- typedef int difference_type;
- typedef int* pointer;
- typedef int& reference;
-
- my_input_iterator();
- reference operator*() const;
- pointer operator->() const;
-
- Self& operator++();
- Self operator++(int);
- friend bool operator==(const Self&, const Self&);
- friend bool operator!=(const Self&, const Self&);
+ typedef tag iterator_category;
+ typedef int value_type;
+ typedef int difference_type;
+ typedef int* pointer;
+ typedef int& reference;
+
+ my_input_iterator();
+ reference operator*() const;
+ pointer operator->() const;
+
+ Self& operator++();
+ Self operator++(int);
+ friend bool operator==(const Self&, const Self&);
+ friend bool operator!=(const Self&, const Self&);
};
-class my_random_access_iterator
-{
- struct tag : std::random_access_iterator_tag {};
- typedef my_random_access_iterator Self;
- int *state_;
+class my_random_access_iterator {
+ struct tag : std::random_access_iterator_tag {};
+ typedef my_random_access_iterator Self;
+ int* state_;
+
public:
- typedef tag iterator_category;
- typedef int value_type;
- typedef int difference_type;
- typedef int* pointer;
- typedef int& reference;
-
- my_random_access_iterator();
- reference operator*() const;
- pointer operator->() const;
- reference operator[](difference_type) const;
-
- Self& operator++();
- Self operator++(int);
- Self& operator--();
- Self operator--(int);
- friend Self& operator+=(Self&, difference_type);
- friend Self& operator-=(Self&, difference_type);
- friend Self operator+(Self, difference_type);
- friend Self operator+(difference_type, Self);
- friend Self operator-(Self, difference_type);
- friend difference_type operator-(Self, Self);
- friend bool operator==(const Self&, const Self&);
- friend bool operator!=(const Self&, const Self&);
- friend bool operator<(const Self&, const Self&);
- friend bool operator>(const Self&, const Self&);
- friend bool operator<=(const Self&, const Self&);
- friend bool operator>=(const Self&, const Self&);
+ typedef tag iterator_category;
+ typedef int value_type;
+ typedef int difference_type;
+ typedef int* pointer;
+ typedef int& reference;
+
+ my_random_access_iterator();
+ reference operator*() const;
+ pointer operator->() const;
+ reference operator[](difference_type) const;
+
+ Self& operator++();
+ Self operator++(int);
+ Self& operator--();
+ Self operator--(int);
+ friend Self& operator+=(Self&, difference_type);
+ friend Self& operator-=(Self&, difference_type);
+ friend Self operator+(Self, difference_type);
+ friend Self operator+(difference_type, Self);
+ friend Self operator-(Self, difference_type);
+ friend difference_type operator-(Self, Self);
+ friend bool operator==(const Self&, const Self&);
+ friend bool operator!=(const Self&, const Self&);
+ friend bool operator<(const Self&, const Self&);
+ friend bool operator>(const Self&, const Self&);
+ friend bool operator<=(const Self&, const Self&);
+ friend bool operator>=(const Self&, const Self&);
};
#if TEST_STD_VER >= 20
-class my_contiguous_iterator
-{
- struct tag : std::contiguous_iterator_tag {};
- typedef my_contiguous_iterator Self;
- int *state_;
+class my_contiguous_iterator {
+ struct tag : std::contiguous_iterator_tag {};
+ typedef my_contiguous_iterator Self;
+ int* state_;
+
public:
- typedef tag iterator_category;
- typedef int value_type;
- typedef int difference_type;
- typedef int* pointer;
- typedef int& reference;
- typedef int element_type; // enable to_address via pointer_traits
-
- my_contiguous_iterator();
- reference operator*() const;
- pointer operator->() const;
- reference operator[](difference_type) const;
-
- Self& operator++();
- Self operator++(int);
- Self& operator--();
- Self operator--(int);
- friend Self& operator+=(Self&, difference_type);
- friend Self& operator-=(Self&, difference_type);
- friend Self operator+(Self, difference_type);
- friend Self operator+(difference_type, Self);
- friend Self operator-(Self, difference_type);
- friend difference_type operator-(Self, Self);
- friend bool operator==(const Self&, const Self&);
- friend bool operator!=(const Self&, const Self&);
- friend bool operator<(const Self&, const Self&);
- friend bool operator>(const Self&, const Self&);
- friend bool operator<=(const Self&, const Self&);
- friend bool operator>=(const Self&, const Self&);
+ typedef tag iterator_category;
+ typedef int value_type;
+ typedef int difference_type;
+ typedef int* pointer;
+ typedef int& reference;
+ typedef int element_type; // enable to_address via pointer_traits
+
+ my_contiguous_iterator();
+ reference operator*() const;
+ pointer operator->() const;
+ reference operator[](difference_type) const;
+
+ Self& operator++();
+ Self operator++(int);
+ Self& operator--();
+ Self operator--(int);
+ friend Self& operator+=(Self&, difference_type);
+ friend Self& operator-=(Self&, difference_type);
+ friend Self operator+(Self, difference_type);
+ friend Self operator+(difference_type, Self);
+ friend Self operator-(Self, difference_type);
+ friend difference_type operator-(Self, Self);
+ friend bool operator==(const Self&, const Self&);
+ friend bool operator!=(const Self&, const Self&);
+ friend bool operator<(const Self&, const Self&);
+ friend bool operator>(const Self&, const Self&);
+ friend bool operator<=(const Self&, const Self&);
+ friend bool operator>=(const Self&, const Self&);
};
#endif
struct fake_deque_iterator : std::deque<int>::iterator {
- using element_type = int;
+ using element_type = int;
};
static_assert(std::__has_random_access_iterator_category<fake_deque_iterator>::value, "");
static_assert(!std::__libcpp_is_contiguous_iterator<fake_deque_iterator>::value, "");
#if TEST_STD_VER >= 20
struct fake2_deque_iterator : std::deque<int>::iterator {
- using iterator_concept = std::contiguous_iterator_tag;
- using element_type = int;
+ using iterator_concept = std::contiguous_iterator_tag;
+ using element_type = int;
};
static_assert(std::__has_random_access_iterator_category<fake2_deque_iterator>::value, "");
static_assert(std::__libcpp_is_contiguous_iterator<fake2_deque_iterator>::value, "");
#endif
-int main(int, char**)
-{
-// basic tests
- static_assert(( std::__libcpp_is_contiguous_iterator<char *>::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<const char *>::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<int *>::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<int **>::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<T *>::value), "");
-
- static_assert((!std::__libcpp_is_contiguous_iterator<my_input_iterator>::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<my_random_access_iterator>::value), "");
+int main(int, char**) {
+ // basic tests
+ static_assert((std::__libcpp_is_contiguous_iterator<char*>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<const char*>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<int*>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<int**>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<T*>::value), "");
+
+ static_assert((!std::__libcpp_is_contiguous_iterator<my_input_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<my_random_access_iterator>::value), "");
#if TEST_STD_VER >= 20
- static_assert(( std::__libcpp_is_contiguous_iterator<my_contiguous_iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<my_contiguous_iterator>::value), "");
#endif
- // move_iterator changes value category, which makes it pretty sketchy to use in optimized codepaths
- static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<char *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<const char *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<int *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<T *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<my_random_access_iterator> >::value), "");
+ // move_iterator changes value category, which makes it pretty sketchy to use in optimized codepaths
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<char*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<const char*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<int*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<T*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<my_random_access_iterator> >::value), "");
#if TEST_STD_VER >= 20
- static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<my_contiguous_iterator> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::move_iterator<my_contiguous_iterator> >::value), "");
#endif
- static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<char *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<const char *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<int *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<T *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<my_random_access_iterator> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<char*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<const char*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<int*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<T*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<my_random_access_iterator> >::value), "");
#if TEST_STD_VER >= 20
- static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<my_contiguous_iterator> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::reverse_iterator<my_contiguous_iterator> >::value), "");
#endif
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<char *> >::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<const char *> >::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<int *> >::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::__wrap_iter<char*> >::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::__wrap_iter<const char*> >::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::__wrap_iter<int*> >::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<T *> >::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<std::__wrap_iter<T *> > >::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::__wrap_iter<T*> >::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::__wrap_iter<std::__wrap_iter<T*> > >::value), "");
- // Here my_random_access_iterator is standing in for some user's fancy pointer type, written pre-C++20.
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<my_random_access_iterator> >::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<std::__wrap_iter<my_random_access_iterator> > >::value), "");
+ // Here my_random_access_iterator is standing in for some user's fancy pointer type, written pre-C++20.
+ static_assert((std::__libcpp_is_contiguous_iterator<std::__wrap_iter<my_random_access_iterator> >::value), "");
+ static_assert(
+ (std::__libcpp_is_contiguous_iterator<std::__wrap_iter<std::__wrap_iter<my_random_access_iterator> > >::value),
+ "");
#if TEST_STD_VER >= 20
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<my_contiguous_iterator> >::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<std::__wrap_iter<my_contiguous_iterator> > >::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::__wrap_iter<my_contiguous_iterator> >::value), "");
+ static_assert(
+ (std::__libcpp_is_contiguous_iterator<std::__wrap_iter<std::__wrap_iter<my_contiguous_iterator> > >::value), "");
#endif
-// iterators in the libc++ test suite
- static_assert((!std::__libcpp_is_contiguous_iterator<cpp17_output_iterator <char *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<cpp17_input_iterator <char *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<forward_iterator <char *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<bidirectional_iterator<char *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<random_access_iterator<char *> >::value), "");
+ // iterators in the libc++ test suite
+ static_assert((!std::__libcpp_is_contiguous_iterator<cpp17_output_iterator<char*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<cpp17_input_iterator<char*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<forward_iterator<char*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<bidirectional_iterator<char*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<random_access_iterator<char*> >::value), "");
#if TEST_STD_VER >= 20
- static_assert(( std::__libcpp_is_contiguous_iterator<contiguous_iterator <char *> >::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<contiguous_iterator<char*> >::value), "");
#endif
- static_assert((!std::__libcpp_is_contiguous_iterator<ThrowingIterator <char *> >::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<NonThrowingIterator <char *> >::value), "");
-
-//
-// iterators from libc++'s containers
-//
-
-// vector
- static_assert(( std::__libcpp_is_contiguous_iterator<std::vector<int>::iterator> ::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::vector<int>::const_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<int>::reverse_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<int>::const_reverse_iterator> ::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::__wrap_iter<std::vector<int>::iterator> >::value), "");
-
-// string
- static_assert(( std::__libcpp_is_contiguous_iterator<std::string::iterator> ::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::string::const_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::string::reverse_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::string::const_reverse_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<ThrowingIterator<char*> >::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<NonThrowingIterator<char*> >::value), "");
+
+ //
+ // iterators from libc++'s containers
+ //
+
+ // vector
+ static_assert((std::__libcpp_is_contiguous_iterator<std::vector<int>::iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::vector<int>::const_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<int>::reverse_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<int>::const_reverse_iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::__wrap_iter<std::vector<int>::iterator> >::value), "");
+
+ // string
+ static_assert((std::__libcpp_is_contiguous_iterator<std::string::iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::string::const_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::string::reverse_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::string::const_reverse_iterator>::value), "");
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- static_assert(( std::__libcpp_is_contiguous_iterator<std::wstring::iterator> ::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::wstring::const_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::wstring::reverse_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::wstring::const_reverse_iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::wstring::iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::wstring::const_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::wstring::reverse_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::wstring::const_reverse_iterator>::value), "");
#endif
-// deque is random-access but not contiguous
- static_assert((!std::__libcpp_is_contiguous_iterator<std::deque<int>::iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::deque<int>::const_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::deque<int>::reverse_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::deque<int>::const_reverse_iterator> ::value), "");
+ // deque is random-access but not contiguous
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::deque<int>::iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::deque<int>::const_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::deque<int>::reverse_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::deque<int>::const_reverse_iterator>::value), "");
-// vector<bool> is random-access but not contiguous
- static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<bool>::iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<bool>::const_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<bool>::reverse_iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<bool>::const_reverse_iterator> ::value), "");
+ // vector<bool> is random-access but not contiguous
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<bool>::iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<bool>::const_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<bool>::reverse_iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::vector<bool>::const_reverse_iterator>::value), "");
#if TEST_STD_VER >= 11
- static_assert(( std::__libcpp_is_contiguous_iterator<std::initializer_list<int>::iterator> ::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::initializer_list<int>::const_iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::initializer_list<int>::iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::initializer_list<int>::const_iterator>::value), "");
#endif
#if TEST_STD_VER >= 17
- static_assert(( std::__libcpp_is_contiguous_iterator<std::string_view::iterator> ::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::string_view::const_iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::string_view::iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::string_view::const_iterator>::value), "");
#endif
#if TEST_STD_VER >= 20
- static_assert(( std::__libcpp_is_contiguous_iterator<std::span< int>::iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::span< int>::reverse_iterator>::value), "");
- static_assert(( std::__libcpp_is_contiguous_iterator<std::span<const int>::iterator> ::value), "");
- static_assert((!std::__libcpp_is_contiguous_iterator<std::span<const int>::reverse_iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::span< int>::iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::span< int>::reverse_iterator>::value), "");
+ static_assert((std::__libcpp_is_contiguous_iterator<std::span<const int>::iterator>::value), "");
+ static_assert((!std::__libcpp_is_contiguous_iterator<std::span<const int>::reverse_iterator>::value), "");
#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx-03/iterators/unwrap_iter.pass.cpp b/libcxx/test/libcxx-03/iterators/unwrap_iter.pass.cpp
index 8ef2be2b0..2a0bad78e 100644
--- a/libcxx/test/libcxx-03/iterators/unwrap_iter.pass.cpp
+++ b/libcxx/test/libcxx-03/iterators/unwrap_iter.pass.cpp
@@ -30,16 +30,23 @@ static_assert(std::is_same<UnwrapT<std::__wrap_iter<int*> >, int*>::value, "");
static_assert(std::is_same<UnwrapT<rev_iter<int*> >, std::reverse_iterator<int*> >::value, "");
static_assert(std::is_same<UnwrapT<rev_rev_iter<int*> >, int*>::value, "");
static_assert(std::is_same<UnwrapT<rev_rev_iter<std::__wrap_iter<int*> > >, int*>::value, "");
-static_assert(std::is_same<UnwrapT<rev_rev_iter<rev_iter<std::__wrap_iter<int*> > > >, rev_iter<std::__wrap_iter<int*> > >::value, "");
+static_assert(
+ std::is_same<UnwrapT<rev_rev_iter<rev_iter<std::__wrap_iter<int*> > > >, rev_iter<std::__wrap_iter<int*> > >::value,
+ "");
static_assert(std::is_same<UnwrapT<random_access_iterator<int*> >, random_access_iterator<int*> >::value, "");
-static_assert(std::is_same<UnwrapT<rev_iter<random_access_iterator<int*> > >, rev_iter<random_access_iterator<int*> > >::value, "");
-static_assert(std::is_same<UnwrapT<rev_rev_iter<random_access_iterator<int*> > >, random_access_iterator<int*> >::value, "");
-static_assert(std::is_same<UnwrapT<rev_rev_iter<rev_iter<random_access_iterator<int*> > > >, rev_iter<random_access_iterator<int*> > >::value, "");
+static_assert(
+ std::is_same<UnwrapT<rev_iter<random_access_iterator<int*> > >, rev_iter<random_access_iterator<int*> > >::value,
+ "");
+static_assert(std::is_same<UnwrapT<rev_rev_iter<random_access_iterator<int*> > >, random_access_iterator<int*> >::value,
+ "");
+static_assert(std::is_same<UnwrapT<rev_rev_iter<rev_iter<random_access_iterator<int*> > > >,
+ rev_iter<random_access_iterator<int*> > >::value,
+ "");
TEST_CONSTEXPR_CXX20 bool test() {
std::string str = "Banane";
- using Iter = std::string::iterator;
+ using Iter = std::string::iterator;
assert(std::__unwrap_iter(str.begin()) == str.data());
assert(std::__unwrap_iter(str.end()) == str.data() + str.size());
diff --git a/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.apple.compile.pass.cpp b/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.apple.compile.pass.cpp
index 6c6b1d44c..a3c0b4dad 100644
--- a/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.apple.compile.pass.cpp
+++ b/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.apple.compile.pass.cpp
@@ -14,17 +14,17 @@
#include <typeinfo>
#if !defined(_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION)
-# error "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION should be defined on Apple platforms"
+# error "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION should be defined on Apple platforms"
#endif
#if defined(__x86_64__) || defined(__ARM_ARCH_7M__)
-# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION != 1
-# error "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION should be 1 (assume RTTI is merged) on Apple platforms"
-# endif
+# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION != 1
+# error "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION should be 1 (assume RTTI is merged) on Apple platforms"
+# endif
#elif defined(__aarch64__)
-# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION != 3
-# error "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION should be 3 (use the special ARM RTTI) on Apple platforms"
-# endif
+# if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION != 3
+# error "_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION should be 3 (use the special ARM RTTI) on Apple platforms"
+# endif
#else
-# error "This test should be updated to pin down the RTTI behavior on this ABI."
+# error "This test should be updated to pin down the RTTI behavior on this ABI."
#endif
diff --git a/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.merged.sh.cpp b/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.merged.sh.cpp
index da82ea1d2..c0eeb69ee 100644
--- a/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.merged.sh.cpp
+++ b/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.merged.sh.cpp
@@ -27,22 +27,30 @@ void register1();
void register2();
#if defined(TU1)
- namespace { struct A { bool x; }; }
- void register1() { registry.push_back(std::type_index(typeid(A))); }
+namespace {
+struct A {
+ bool x;
+};
+} // namespace
+void register1() { registry.push_back(std::type_index(typeid(A))); }
#elif defined(TU2)
- namespace { struct A { int x, y; }; }
- void register2() { registry.push_back(std::type_index(typeid(A))); }
+namespace {
+struct A {
+ int x, y;
+};
+} // namespace
+void register2() { registry.push_back(std::type_index(typeid(A))); }
#elif defined(MAIN)
- std::vector<std::type_index> registry;
+std::vector<std::type_index> registry;
- int main(int, char**) {
- register1();
- register2();
+int main(int, char**) {
+ register1();
+ register2();
- assert(registry.size() == 2);
- assert(registry[0] != registry[1]);
- return 0;
- }
+ assert(registry.size() == 2);
+ assert(registry[0] != registry[1]);
+ return 0;
+}
#else
-# error
+# error
#endif
diff --git a/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.unmerged.sh.cpp b/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.unmerged.sh.cpp
index 9b94fcbc1..eecb4a047 100644
--- a/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.unmerged.sh.cpp
+++ b/libcxx/test/libcxx-03/language.support/support.rtti/type.info/type_info.comparison.unmerged.sh.cpp
@@ -24,22 +24,30 @@ void register1();
void register2();
#if defined(TU1)
- namespace { struct A { bool x; }; }
- void register1() { registry.push_back(std::type_index(typeid(A))); }
+namespace {
+struct A {
+ bool x;
+};
+} // namespace
+void register1() { registry.push_back(std::type_index(typeid(A))); }
#elif defined(TU2)
- namespace { struct A { int x, y; }; }
- void register2() { registry.push_back(std::type_index(typeid(A))); }
+namespace {
+struct A {
+ int x, y;
+};
+} // namespace
+void register2() { registry.push_back(std::type_index(typeid(A))); }
#elif defined(MAIN)
- std::vector<std::type_index> registry;
+std::vector<std::type_index> registry;
- int main(int, char**) {
- register1();
- register2();
+int main(int, char**) {
+ register1();
+ register2();
- assert(registry.size() == 2);
- assert(registry[0] == registry[1]);
- return 0;
- }
+ assert(registry.size() == 2);
+ assert(registry[0] == registry[1]);
+ return 0;
+}
#else
-# error
+# error
#endif
diff --git a/libcxx/test/libcxx-03/libcpp_freestanding.sh.cpp b/libcxx/test/libcxx-03/libcpp_freestanding.sh.cpp
index 8dd7a8ac8..c476f0f06 100644
--- a/libcxx/test/libcxx-03/libcpp_freestanding.sh.cpp
+++ b/libcxx/test/libcxx-03/libcpp_freestanding.sh.cpp
@@ -15,6 +15,6 @@
#include <__config>
#if defined(FREESTANDING) != defined(_LIBCPP_FREESTANDING)
-#error _LIBCPP_FREESTANDING should be defined in freestanding mode and not \
+# error _LIBCPP_FREESTANDING should be defined in freestanding mode and not \
defined in non-freestanding mode
#endif
diff --git a/libcxx/test/libcxx-03/localization/locale.categories/__scan_keyword.pass.cpp b/libcxx/test/libcxx-03/localization/locale.categories/__scan_keyword.pass.cpp
index 1ecf378de..12f92b731 100644
--- a/libcxx/test/libcxx-03/localization/locale.categories/__scan_keyword.pass.cpp
+++ b/libcxx/test/libcxx-03/localization/locale.categories/__scan_keyword.pass.cpp
@@ -40,82 +40,75 @@
#include "test_macros.h"
-int main(int, char**)
-{
- const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(std::locale::classic());
- std::ios_base::iostate err = std::ios_base::goodbit;
- {
- const char input[] = "a";
- const char* in = input;
- std::string keys[] = {"a", "abb"};
- err = std::ios_base::goodbit;
- std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
- keys, keys+sizeof(keys)/sizeof(keys[0]),
- ct, err);
- assert(k - keys == 0);
- assert(in == input+1);
- assert(err == std::ios_base::eofbit);
- }
- {
- const char input[] = "abc";
- const char* in = input;
- std::string keys[] = {"a", "abb"};
- err = std::ios_base::goodbit;
- std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
- keys, keys+sizeof(keys)/sizeof(keys[0]),
- ct, err);
- assert(k - keys == 2);
- assert(in == input+2);
- assert(err == std::ios_base::failbit);
- }
- {
- const char input[] = "abb";
- const char* in = input;
- std::string keys[] = {"a", "abb"};
- err = std::ios_base::goodbit;
- std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
- keys, keys+sizeof(keys)/sizeof(keys[0]),
- ct, err);
- assert(k - keys == 1);
- assert(in == input+3);
- assert(err == std::ios_base::eofbit);
- }
- {
- const char input[] = "Tue ";
- const char* in = input;
- std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
- err = std::ios_base::goodbit;
- std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
- keys, keys+sizeof(keys)/sizeof(keys[0]),
- ct, err);
- assert(k - keys == 2);
- assert(in == input+3);
- assert(err == std::ios_base::goodbit);
- }
- {
- const char input[] = "tue ";
- const char* in = input;
- std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
- err = std::ios_base::goodbit;
- std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
- keys, keys+sizeof(keys)/sizeof(keys[0]),
- ct, err);
- assert(k - keys == 4);
- assert(in == input+0);
- assert(err == std::ios_base::failbit);
- }
- {
- const char input[] = "tue ";
- const char* in = input;
- std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
- err = std::ios_base::goodbit;
- std::string* k = std::__scan_keyword(in, input+sizeof(input)-1,
- keys, keys+sizeof(keys)/sizeof(keys[0]),
- ct, err, false);
- assert(k - keys == 2);
- assert(in == input+3);
- assert(err == std::ios_base::goodbit);
- }
+int main(int, char**) {
+ const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(std::locale::classic());
+ std::ios_base::iostate err = std::ios_base::goodbit;
+ {
+ const char input[] = "a";
+ const char* in = input;
+ std::string keys[] = {"a", "abb"};
+ err = std::ios_base::goodbit;
+ std::string* k =
+ std::__scan_keyword(in, input + sizeof(input) - 1, keys, keys + sizeof(keys) / sizeof(keys[0]), ct, err);
+ assert(k - keys == 0);
+ assert(in == input + 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char input[] = "abc";
+ const char* in = input;
+ std::string keys[] = {"a", "abb"};
+ err = std::ios_base::goodbit;
+ std::string* k =
+ std::__scan_keyword(in, input + sizeof(input) - 1, keys, keys + sizeof(keys) / sizeof(keys[0]), ct, err);
+ assert(k - keys == 2);
+ assert(in == input + 2);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const char input[] = "abb";
+ const char* in = input;
+ std::string keys[] = {"a", "abb"};
+ err = std::ios_base::goodbit;
+ std::string* k =
+ std::__scan_keyword(in, input + sizeof(input) - 1, keys, keys + sizeof(keys) / sizeof(keys[0]), ct, err);
+ assert(k - keys == 1);
+ assert(in == input + 3);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const char input[] = "Tue ";
+ const char* in = input;
+ std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+ err = std::ios_base::goodbit;
+ std::string* k =
+ std::__scan_keyword(in, input + sizeof(input) - 1, keys, keys + sizeof(keys) / sizeof(keys[0]), ct, err);
+ assert(k - keys == 2);
+ assert(in == input + 3);
+ assert(err == std::ios_base::goodbit);
+ }
+ {
+ const char input[] = "tue ";
+ const char* in = input;
+ std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+ err = std::ios_base::goodbit;
+ std::string* k =
+ std::__scan_keyword(in, input + sizeof(input) - 1, keys, keys + sizeof(keys) / sizeof(keys[0]), ct, err);
+ assert(k - keys == 4);
+ assert(in == input + 0);
+ assert(err == std::ios_base::failbit);
+ }
+ {
+ const char input[] = "tue ";
+ const char* in = input;
+ std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"};
+ err = std::ios_base::goodbit;
+ std::string* k =
+ std::__scan_keyword(in, input + sizeof(input) - 1, keys, keys + sizeof(keys) / sizeof(keys[0]), ct, err, false);
+ assert(k - keys == 2);
+ assert(in == input + 3);
+ assert(err == std::ios_base::goodbit);
+ }
return 0;
}
diff --git a/libcxx/test/libcxx-03/localization/locales/locale.abort.pass.cpp b/libcxx/test/libcxx-03/localization/locales/locale.abort.pass.cpp
index 9a47eb8f1..7d42d0c76 100644
--- a/libcxx/test/libcxx-03/localization/locales/locale.abort.pass.cpp
+++ b/libcxx/test/libcxx-03/localization/locales/locale.abort.pass.cpp
@@ -23,14 +23,11 @@
#include "test_macros.h"
-
-void exit_success(int) {
- std::_Exit(EXIT_SUCCESS);
-}
+void exit_success(int) { std::_Exit(EXIT_SUCCESS); }
int main(int, char**) {
- std::signal(SIGABRT, exit_success);
- std::locale loc(NULL);
- (void)loc;
- return EXIT_FAILURE;
+ std::signal(SIGABRT, exit_success);
+ std::locale loc(NULL);
+ (void)loc;
+ return EXIT_FAILURE;
}
diff --git a/libcxx/test/libcxx-03/localization/locales/locale.category.abort.pass.cpp b/libcxx/test/libcxx-03/localization/locales/locale.category.abort.pass.cpp
index 9b321e6b1..a543985a0 100644
--- a/libcxx/test/libcxx-03/localization/locales/locale.category.abort.pass.cpp
+++ b/libcxx/test/libcxx-03/localization/locales/locale.category.abort.pass.cpp
@@ -23,14 +23,11 @@
#include "test_macros.h"
-
-void exit_success(int) {
- std::_Exit(EXIT_SUCCESS);
-}
+void exit_success(int) { std::_Exit(EXIT_SUCCESS); }
int main(int, char**) {
- std::signal(SIGABRT, exit_success);
- std::locale loc(std::locale(), NULL, std::locale::ctype);
- (void)loc;
- return EXIT_FAILURE;
+ std::signal(SIGABRT, exit_success);
+ std::locale loc(std::locale(), NULL, std::locale::ctype);
+ (void)loc;
+ return EXIT_FAILURE;
}
diff --git a/libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp b/libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
index 072c85a11..040963c18 100644
--- a/libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
+++ b/libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp
@@ -24,33 +24,28 @@
#include "test_macros.h"
-struct my_facet
- : public std::locale::facet
-{
- static int count;
- my_facet(unsigned refs = 0)
- : std::locale::facet(refs)
- {++count;}
-
- ~my_facet() {--count;}
+struct my_facet : public std::locale::facet {
+ static int count;
+ my_facet(unsigned refs = 0) : std::locale::facet(refs) { ++count; }
+
+ ~my_facet() { --count; }
};
int my_facet::count = 0;
-int main(int, char**)
-{
- my_facet* f = new my_facet;
- f->__add_shared();
- assert(my_facet::count == 1);
- f->__release_shared();
- assert(my_facet::count == 0);
- f = new my_facet(1);
- f->__add_shared();
- assert(my_facet::count == 1);
- f->__release_shared();
- assert(my_facet::count == 1);
- f->__release_shared();
- assert(my_facet::count == 0);
+int main(int, char**) {
+ my_facet* f = new my_facet;
+ f->__add_shared();
+ assert(my_facet::count == 1);
+ f->__release_shared();
+ assert(my_facet::count == 0);
+ f = new my_facet(1);
+ f->__add_shared();
+ assert(my_facet::count == 1);
+ f->__release_shared();
+ assert(my_facet::count == 1);
+ f->__release_shared();
+ assert(my_facet::count == 0);
return 0;
}
diff --git a/libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.id/id.pass.cpp b/libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.id/id.pass.cpp
index 5e0113474..2a98da89e 100644
--- a/libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.id/id.pass.cpp
+++ b/libcxx/test/libcxx-03/localization/locales/locale/locale.types/locale.id/id.pass.cpp
@@ -27,27 +27,26 @@ std::locale::id id0;
std::locale::id id2;
std::locale::id id1;
-int main(int, char**)
-{
- long id = id0.__get();
- assert(id0.__get() == id+0);
- assert(id0.__get() == id+0);
- assert(id0.__get() == id+0);
- assert(id1.__get() == id+1);
- assert(id1.__get() == id+1);
- assert(id1.__get() == id+1);
- assert(id2.__get() == id+2);
- assert(id2.__get() == id+2);
- assert(id2.__get() == id+2);
- assert(id0.__get() == id+0);
- assert(id0.__get() == id+0);
- assert(id0.__get() == id+0);
- assert(id1.__get() == id+1);
- assert(id1.__get() == id+1);
- assert(id1.__get() == id+1);
- assert(id2.__get() == id+2);
- assert(id2.__get() == id+2);
- assert(id2.__get() == id+2);
+int main(int, char**) {
+ long id = id0.__get();
+ assert(id0.__get() == id + 0);
+ assert(id0.__get() == id + 0);
+ assert(id0.__get() == id + 0);
+ assert(id1.__get() == id + 1);
+ assert(id1.__get() == id + 1);
+ assert(id1.__get() == id + 1);
+ assert(id2.__get() == id + 2);
+ assert(id2.__get() == id + 2);
+ assert(id2.__get() == id + 2);
+ assert(id0.__get() == id + 0);
+ assert(id0.__get() == id + 0);
+ assert(id0.__get() == id + 0);
+ assert(id1.__get() == id + 1);
+ assert(id1.__get() == id + 1);
+ assert(id1.__get() == id + 1);
+ assert(id2.__get() == id + 2);
+ assert(id2.__get() == id + 2);
+ assert(id2.__get() == id + 2);
return 0;
}
diff --git a/libcxx/test/libcxx-03/localization/locales/use_facet.abort.pass.cpp b/libcxx/test/libcxx-03/localization/locales/use_facet.abort.pass.cpp
index 9b4755a81..bfca71f10 100644
--- a/libcxx/test/libcxx-03/localization/locales/use_facet.abort.pass.cpp
+++ b/libcxx/test/libcxx-03/localization/locales/use_facet.abort.pass.cpp
@@ -21,19 +21,16 @@
#include "test_macros.h"
-
struct my_facet : public std::locale::facet {
- static std::locale::id id;
+ static std::locale::id id;
};
std::locale::id my_facet::id;
-void exit_success(int) {
- std::_Exit(EXIT_SUCCESS);
-}
+void exit_success(int) { std::_Exit(EXIT_SUCCESS); }
int main(int, char**) {
- std::signal(SIGABRT, exit_success);
- std::use_facet<my_facet>(std::locale());
- return EXIT_FAILURE;
+ std::signal(SIGABRT, exit_success);
+ std::use_facet<my_facet>(std::locale());
+ return EXIT_FAILURE;
}
diff --git a/libcxx/test/libcxx-03/memory/allocation_guard.pass.cpp b/libcxx/test/libcxx-03/memory/allocation_guard.pass.cpp
index 20c05b381..dc6a3213c 100644
--- a/libcxx/test/libcxx-03/memory/allocation_guard.pass.cpp
+++ b/libcxx/test/libcxx-03/memory/allocation_guard.pass.cpp
@@ -30,12 +30,12 @@ using A = test_allocator<int>;
// assignment).
template <class T>
struct AssignableAllocator {
- using size_type = unsigned;
+ using size_type = unsigned;
using difference_type = int;
- using value_type = T;
- using pointer = value_type*;
- using const_pointer = const value_type*;
- using reference = typename std::add_lvalue_reference<value_type>::type;
+ using value_type = T;
+ using pointer = value_type*;
+ using const_pointer = const value_type*;
+ using reference = typename std::add_lvalue_reference<value_type>::type;
using const_reference = typename std::add_lvalue_reference<const value_type>::type;
template <class U>
@@ -45,12 +45,9 @@ struct AssignableAllocator {
test_allocator_statistics* stats_ = nullptr;
- explicit AssignableAllocator(test_allocator_statistics& stats) : stats_(&stats) {
- ++stats_->count;
- }
+ explicit AssignableAllocator(test_allocator_statistics& stats) : stats_(&stats) { ++stats_->count; }
- TEST_CONSTEXPR_CXX14 AssignableAllocator(const AssignableAllocator& rhs) TEST_NOEXCEPT
- : stats_(rhs.stats_) {
+ TEST_CONSTEXPR_CXX14 AssignableAllocator(const AssignableAllocator& rhs) TEST_NOEXCEPT : stats_(rhs.stats_) {
if (stats_ != nullptr) {
++stats_->count;
++stats_->copied;
diff --git a/libcxx/test/libcxx-03/memory/allocator_void.trivial.compile.pass.cpp b/libcxx/test/libcxx-03/memory/allocator_void.trivial.compile.pass.cpp
index b7dfc190e..2b1fc6525 100644
--- a/libcxx/test/libcxx-03/memory/allocator_void.trivial.compile.pass.cpp
+++ b/libcxx/test/libcxx-03/memory/allocator_void.trivial.compile.pass.cpp
@@ -17,7 +17,7 @@
#include <type_traits>
typedef std::allocator<void> A1;
-struct A2 : std::allocator<void> { };
+struct A2 : std::allocator<void> {};
static_assert(std::is_trivially_default_constructible<A1>::value, "");
static_assert(std::is_trivially_copyable<A1>::value, "");
diff --git a/libcxx/test/libcxx-03/memory/allocator_volatile.verify.cpp b/libcxx/test/libcxx-03/memory/allocator_volatile.verify.cpp
index 53fdc08e7..3a9ccb2ce 100644
--- a/libcxx/test/libcxx-03/memory/allocator_volatile.verify.cpp
+++ b/libcxx/test/libcxx-03/memory/allocator_volatile.verify.cpp
@@ -10,5 +10,5 @@
#include <memory>
-std::allocator<const int> A1; // expected-error@*:* {{std::allocator does not support const types}}
+std::allocator<const int> A1; // expected-error@*:* {{std::allocator does not support const types}}
std::allocator<volatile int> A2; // expected-error@*:* {{std::allocator does not support volatile types}}
diff --git a/libcxx/test/libcxx-03/memory/is_allocator.pass.cpp b/libcxx/test/libcxx-03/memory/is_allocator.pass.cpp
index cf11d077b..7c5f9d129 100644
--- a/libcxx/test/libcxx-03/memory/is_allocator.pass.cpp
+++ b/libcxx/test/libcxx-03/memory/is_allocator.pass.cpp
@@ -23,21 +23,18 @@
#include "test_allocator.h"
template <typename T>
-void test_allocators()
-{
- static_assert(!std::__is_allocator<T>::value, "" );
- static_assert( std::__is_allocator<std::allocator<T>>::value, "" );
- static_assert( std::__is_allocator<test_allocator<T>>::value, "" );
- static_assert( std::__is_allocator<min_allocator<T>>::value, "" );
+void test_allocators() {
+ static_assert(!std::__is_allocator<T>::value, "");
+ static_assert(std::__is_allocator<std::allocator<T>>::value, "");
+ static_assert(std::__is_allocator<test_allocator<T>>::value, "");
+ static_assert(std::__is_allocator<min_allocator<T>>::value, "");
}
+int main(int, char**) {
+ // test_allocators<void>();
+ test_allocators<char>();
+ test_allocators<int>();
+ test_allocators<std::string>();
-int main(int, char**)
-{
- // test_allocators<void>();
- test_allocators<char>();
- test_allocators<int>();
- test_allocators<std::string>();
-
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx-03/memory/swap_allocator.pass.cpp b/libcxx/test/libcxx-03/memory/swap_allocator.pass.cpp
index f70f8134d..c905b895f 100644
--- a/libcxx/test/libcxx-03/memory/swap_allocator.pass.cpp
+++ b/libcxx/test/libcxx-03/memory/swap_allocator.pass.cpp
@@ -23,17 +23,14 @@
template <bool Propagate, bool Noexcept>
struct Alloc {
- int i = 0;
+ int i = 0;
Alloc() = default;
Alloc(int set_i) : i(set_i) {}
- using value_type = int;
+ using value_type = int;
using propagate_on_container_swap = std::integral_constant<bool, Propagate>;
- friend void swap(Alloc& a1, Alloc& a2) TEST_NOEXCEPT_COND(Noexcept) {
- std::swap(a1.i, a2.i);
- }
-
+ friend void swap(Alloc& a1, Alloc& a2) TEST_NOEXCEPT_COND(Noexcept) { std::swap(a1.i, a2.i); }
};
using PropagatingAlloc = Alloc</*Propagate=*/true, /*Noexcept=*/true>;
@@ -66,18 +63,18 @@ int main(int, char**) {
static_assert(noexcept(std::__swap_allocator(noexcept_alloc, noexcept_alloc)), "");
}
-#if TEST_STD_VER > 11
+# if TEST_STD_VER > 11
{ // From C++14, `__swap_allocator` is unconditionally noexcept.
ThrowingSwapAlloc throwing_alloc;
static_assert(noexcept(std::__swap_allocator(throwing_alloc, throwing_alloc)), "");
}
-#else
+# else
{ // Until C++14, `__swap_allocator` is only noexcept if the underlying `swap` function is `noexcept`.
ThrowingSwapAlloc throwing_alloc;
static_assert(!noexcept(std::__swap_allocator(throwing_alloc, throwing_alloc)), "");
}
-#endif // TEST_STD_VER > 11
-#endif // TEST_STD_VER >= 11
+# endif // TEST_STD_VER > 11
+#endif // TEST_STD_VER >= 11
return 0;
}
diff --git a/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_arg.pass.cpp b/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_arg.pass.cpp
index 8a7367bf2..2ef4fdd6e 100644
--- a/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_arg.pass.cpp
+++ b/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_arg.pass.cpp
@@ -31,9 +31,7 @@ __attribute__((noinline)) bool get_val(std::unique_ptr<Node> /*unused*/) {
return true;
}
-__attribute__((noinline)) void expect_1(int* shared, bool /*unused*/) {
- assert(*shared == 1);
-}
+__attribute__((noinline)) void expect_1(int* shared, bool /*unused*/) { assert(*shared == 1); }
int main(int, char**) {
int shared = 0;
diff --git a/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp b/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
index 8752ba5a0..cc9a95561 100644
--- a/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
+++ b/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
@@ -26,9 +26,8 @@ struct Base {
int* cur_idx;
const char id;
- explicit Base(char* buf, int* idx, char ch)
- : shared_buff(buf), cur_idx(idx), id(ch) {}
- Base(const Base& other) = default;
+ explicit Base(char* buf, int* idx, char ch) : shared_buff(buf), cur_idx(idx), id(ch) {}
+ Base(const Base& other) = default;
Base& operator=(const Base&) = delete;
~Base() { shared_buff[(*cur_idx)++] = id; }
};
@@ -45,17 +44,13 @@ struct C : Base {
explicit C(char* buf, int* idx) : Base(buf, idx, 'C') {}
};
-__attribute__((noinline)) void func(A /*unused*/, std::unique_ptr<B> /*unused*/,
- C /*unused*/) {
- call_something();
-}
+__attribute__((noinline)) void func(A /*unused*/, std::unique_ptr<B> /*unused*/, C /*unused*/) { call_something(); }
int main(int, char**) {
char shared_buf[3] = {'0', '0', '0'};
- int cur_idx = 0;
+ int cur_idx = 0;
- func(A(shared_buf, &cur_idx), std::unique_ptr<B>(new B(shared_buf, &cur_idx)),
- C(shared_buf, &cur_idx));
+ func(A(shared_buf, &cur_idx), std::unique_ptr<B>(new B(shared_buf, &cur_idx)), C(shared_buf, &cur_idx));
#if defined(TEST_ABI_MICROSOFT)
// On Microsoft ABI, the dtor order is always A,B,C (because callee-destroyed)
diff --git a/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_ret.pass.cpp b/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_ret.pass.cpp
index 65e9069e0..6bb097f74 100644
--- a/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_ret.pass.cpp
+++ b/libcxx/test/libcxx-03/memory/trivial_abi/unique_ptr_ret.pass.cpp
@@ -21,7 +21,7 @@ __attribute__((noinline)) void call_something() { asm volatile(""); }
struct Node {
explicit Node() {}
- Node(const Node&) = default;
+ Node(const Node&) = default;
Node& operator=(const Node&) = default;
~Node() {}
};
@@ -39,7 +39,7 @@ __attribute__((noinline)) std::unique_ptr<Node> make_val(void** local_addr) {
int main(int, char**) {
void* local_addr = nullptr;
- auto ret = make_val(&local_addr);
+ auto ret = make_val(&local_addr);
assert(local_addr != nullptr);
// Without trivial_abi, &ret == local_addr because the return value
diff --git a/libcxx/test/libcxx-03/memory/trivial_abi/weak_ptr_ret.pass.cpp b/libcxx/test/libcxx-03/memory/trivial_abi/weak_ptr_ret.pass.cpp
index 0b1a434ee..12ace6539 100644
--- a/libcxx/test/libcxx-03/memory/trivial_abi/weak_ptr_ret.pass.cpp
+++ b/libcxx/test/libcxx-03/memory/trivial_abi/weak_ptr_ret.pass.cpp
@@ -21,13 +21,12 @@ __attribute__((noinline)) void call_something() { asm volatile(""); }
struct Node {
explicit Node() {}
- Node(const Node&) = default;
+ Node(const Node&) = default;
Node& operator=(const Node&) = default;
~Node() {}
};
-__attribute__((noinline)) std::weak_ptr<Node>
-make_val(std::shared_ptr<Node>& sptr, void** local_addr) {
+__attribute__((noinline)) std::weak_ptr<Node> make_val(std::shared_ptr<Node>& sptr, void** local_addr) {
call_something();
std::weak_ptr<Node> ret;
@@ -40,8 +39,8 @@ make_val(std::shared_ptr<Node>& sptr, void** local_addr) {
}
int main(int, char**) {
- void* local_addr = nullptr;
- auto sptr = std::make_shared<Node>();
+ void* local_addr = nullptr;
+ auto sptr = std::make_shared<Node>();
std::weak_ptr<Node> ret = make_val(sptr, &local_addr);
assert(local_addr != nullptr);
diff --git a/libcxx/test/libcxx-03/numerics/clamp_to_integral.pass.cpp b/libcxx/test/libcxx-03/numerics/clamp_to_integral.pass.cpp
index 68d55afa1..192e61f25 100644
--- a/libcxx/test/libcxx-03/numerics/clamp_to_integral.pass.cpp
+++ b/libcxx/test/libcxx-03/numerics/clamp_to_integral.pass.cpp
@@ -23,7 +23,7 @@ template <class IntT>
void test() {
typedef std::numeric_limits<IntT> Lim;
const bool MaxIsRepresentable = sizeof(IntT) < 8;
- const bool IsSigned = std::is_signed<IntT>::value;
+ const bool IsSigned = std::is_signed<IntT>::value;
struct TestCase {
double Input;
IntT Expect;
@@ -31,8 +31,7 @@ void test() {
} TestCases[] = {
{0, 0, true},
{1, 1, true},
- {IsSigned ? static_cast<IntT>(-1) : 0,
- IsSigned ? static_cast<IntT>(-1) : 0, true},
+ {IsSigned ? static_cast<IntT>(-1) : 0, IsSigned ? static_cast<IntT>(-1) : 0, true},
{Lim::lowest(), Lim::lowest(), true},
{static_cast<double>(Lim::max()), Lim::max(), MaxIsRepresentable},
{static_cast<double>(Lim::max()) + 1, Lim::max(), false},
@@ -63,11 +62,10 @@ void test_float() {
} TestCases[] = {
{0, 0, true},
{1, 1, true},
- {IsSigned ? static_cast<IntT>(-1) : 0,
- IsSigned ? static_cast<IntT>(-1) : 0, true},
+ {IsSigned ? static_cast<IntT>(-1) : 0, IsSigned ? static_cast<IntT>(-1) : 0, true},
{Lim::lowest(), Lim::lowest(), true},
- {static_cast<float>(Lim::max()), Lim::max(), MaxIsRepresentable },
- {nextafter(static_cast<float>(Lim::max()), INFINITY), Lim::max(), false},
+ {static_cast<float>(Lim::max()), Lim::max(), MaxIsRepresentable},
+ {nextafter(static_cast<float>(Lim::max()), INFINITY), Lim::max(), false},
};
for (TestCase TC : TestCases) {
auto res = std::__clamp_to_integral<IntT>(TC.Input);
diff --git a/libcxx/test/libcxx-03/numerics/complex.number/__sqr.pass.cpp b/libcxx/test/libcxx-03/numerics/complex.number/__sqr.pass.cpp
index 97f4a2419..bc2cb9404 100644
--- a/libcxx/test/libcxx-03/numerics/complex.number/__sqr.pass.cpp
+++ b/libcxx/test/libcxx-03/numerics/complex.number/__sqr.pass.cpp
@@ -18,67 +18,62 @@
#include "test_macros.h"
template <class T>
-void
-test()
-{
- const T tolerance = std::is_same<T, float>::value ? 1.e-6 : 1.e-14;
+void test() {
+ const T tolerance = std::is_same<T, float>::value ? 1.e-6 : 1.e-14;
- typedef std::complex<T> cplx;
- struct test_case
- {
- cplx value;
- cplx expected;
- };
+ typedef std::complex<T> cplx;
+ struct test_case {
+ cplx value;
+ cplx expected;
+ };
- const test_case cases[] = {
- {cplx( 0, 0), cplx( 0, 0)},
- {cplx( 1, 0), cplx( 1, 0)},
- {cplx( 2, 0), cplx( 4, 0)},
- {cplx(-1, 0), cplx( 1, 0)},
- {cplx( 0, 1), cplx(-1, 0)},
- {cplx( 0, 2), cplx(-4, 0)},
- {cplx( 0, -1), cplx(-1, 0)},
- {cplx( 1, 1), cplx( 0, 2)},
- {cplx( 1, -1), cplx( 0, -2)},
- {cplx(-1, -1), cplx( 0, 2)},
- {cplx(0.5, 0), cplx(0.25, 0)},
- };
+ const test_case cases[] = {
+ {cplx(0, 0), cplx(0, 0)},
+ {cplx(1, 0), cplx(1, 0)},
+ {cplx(2, 0), cplx(4, 0)},
+ {cplx(-1, 0), cplx(1, 0)},
+ {cplx(0, 1), cplx(-1, 0)},
+ {cplx(0, 2), cplx(-4, 0)},
+ {cplx(0, -1), cplx(-1, 0)},
+ {cplx(1, 1), cplx(0, 2)},
+ {cplx(1, -1), cplx(0, -2)},
+ {cplx(-1, -1), cplx(0, 2)},
+ {cplx(0.5, 0), cplx(0.25, 0)},
+ };
- const unsigned num_cases = sizeof(cases) / sizeof(test_case);
- for (unsigned i = 0; i < num_cases; ++i)
- {
- const test_case& test = cases[i];
- const std::complex<T> actual = std::__sqr(test.value);
- assert(std::abs(actual.real() - test.expected.real()) < tolerance);
- assert(std::abs(actual.imag() - test.expected.imag()) < tolerance);
- }
+ const unsigned num_cases = sizeof(cases) / sizeof(test_case);
+ for (unsigned i = 0; i < num_cases; ++i) {
+ const test_case& test = cases[i];
+ const std::complex<T> actual = std::__sqr(test.value);
+ assert(std::abs(actual.real() - test.expected.real()) < tolerance);
+ assert(std::abs(actual.imag() - test.expected.imag()) < tolerance);
+ }
- const cplx nan1 = std::__sqr(cplx(NAN, 0));
- assert(std::isnan(nan1.real()));
- assert(std::isnan(nan1.imag()));
+ const cplx nan1 = std::__sqr(cplx(NAN, 0));
+ assert(std::isnan(nan1.real()));
+ assert(std::isnan(nan1.imag()));
- const cplx nan2 = std::__sqr(cplx(0, NAN));
- assert(std::isnan(nan2.real()));
- assert(std::isnan(nan2.imag()));
+ const cplx nan2 = std::__sqr(cplx(0, NAN));
+ assert(std::isnan(nan2.real()));
+ assert(std::isnan(nan2.imag()));
- const cplx nan3 = std::__sqr(cplx(NAN, NAN));
- assert(std::isnan(nan3.real()));
- assert(std::isnan(nan3.imag()));
+ const cplx nan3 = std::__sqr(cplx(NAN, NAN));
+ assert(std::isnan(nan3.real()));
+ assert(std::isnan(nan3.imag()));
- const cplx inf1 = std::__sqr(cplx(INFINITY, 0));
- assert(std::isinf(inf1.real()));
- assert(inf1.real() > 0);
+ const cplx inf1 = std::__sqr(cplx(INFINITY, 0));
+ assert(std::isinf(inf1.real()));
+ assert(inf1.real() > 0);
- const cplx inf2 = std::__sqr(cplx(0, INFINITY));
- assert(std::isinf(inf2.real()));
- assert(inf2.real() < 0);
+ const cplx inf2 = std::__sqr(cplx(0, INFINITY));
+ assert(std::isinf(inf2.real()));
+ assert(inf2.real() < 0);
}
-int main(int, char**)
-{
- test<float>();
- test<double>();
- test<long double>();
+int main(int, char**) {
+ test<float>();
+ test<double>();
+ test<long double>();
return 0;
}
diff --git a/libcxx/test/libcxx-03/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp b/libcxx/test/libcxx-03/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
index 13d1bfcb8..bb686db55 100644
--- a/libcxx/test/libcxx-03/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
+++ b/libcxx/test/libcxx-03/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
@@ -24,13 +24,11 @@
#include "test_macros.h"
-int main(int, char**)
-{
- static_assert((std::is_same<std::condition_variable::native_handle_type,
- pthread_cond_t*>::value), "");
- std::condition_variable cv;
- std::condition_variable::native_handle_type h = cv.native_handle();
- assert(h != nullptr);
+int main(int, char**) {
+ static_assert((std::is_same<std::condition_variable::native_handle_type, pthread_cond_t*>::value), "");
+ std::condition_variable cv;
+ std::condition_variable::native_handle_type h = cv.native_handle();
+ assert(h != nullptr);
return 0;
}
diff --git a/libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp b/libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
index 3de6635f1..b5d239b9e 100644
--- a/libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
+++ b/libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
@@ -22,11 +22,10 @@
#include "test_macros.h"
-int main(int, char**)
-{
- std::mutex m;
- pthread_mutex_t* h = m.native_handle();
- assert(h);
+int main(int, char**) {
+ std::mutex m;
+ pthread_mutex_t* h = m.native_handle();
+ assert(h);
return 0;
}
diff --git a/libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp b/libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
index d76b3d71d..aad5e05aa 100644
--- a/libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
+++ b/libcxx/test/libcxx-03/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
@@ -22,11 +22,10 @@
#include "test_macros.h"
-int main(int, char**)
-{
- std::recursive_mutex m;
- pthread_mutex_t* h = m.native_handle();
- assert(h);
+int main(int, char**) {
+ std::recursive_mutex m;
+ pthread_mutex_t* h = m.native_handle();
+ assert(h);
return 0;
}
diff --git a/libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp b/libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
index 96ec33325..870bcafd6 100644
--- a/libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
+++ b/libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
@@ -23,37 +23,38 @@
#include "test_macros.h"
-class G
-{
- int alive_;
+class G {
+ int alive_;
+
public:
- static int n_alive;
- static bool op_run;
-
- G() : alive_(1) {++n_alive;}
- G(const G& g) : alive_(g.alive_) {++n_alive;}
- ~G() {alive_ = 0; --n_alive;}
-
- void operator()()
- {
- assert(alive_ == 1);
- assert(n_alive >= 1);
- op_run = true;
- }
+ static int n_alive;
+ static bool op_run;
+
+ G() : alive_(1) { ++n_alive; }
+ G(const G& g) : alive_(g.alive_) { ++n_alive; }
+ ~G() {
+ alive_ = 0;
+ --n_alive;
+ }
+
+ void operator()() {
+ assert(alive_ == 1);
+ assert(n_alive >= 1);
+ op_run = true;
+ }
};
int G::n_alive = 0;
bool G::op_run = false;
-int main(int, char**)
-{
- {
- G g;
- std::thread t0(g);
- pthread_t pid = t0.native_handle();
- assert(pid != 0);
- t0.join();
- }
+int main(int, char**) {
+ {
+ G g;
+ std::thread t0(g);
+ pthread_t pid = t0.native_handle();
+ assert(pid != 0);
+ t0.join();
+ }
return 0;
}
diff --git a/libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/types.pass.cpp b/libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/types.pass.cpp
index bb60647ef..a371670c1 100644
--- a/libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/types.pass.cpp
+++ b/libcxx/test/libcxx-03/thread/thread.threads/thread.thread.class/types.pass.cpp
@@ -23,9 +23,8 @@
#include "test_macros.h"
-int main(int, char**)
-{
- static_assert((std::is_same<std::thread::native_handle_type, pthread_t>::value), "");
+int main(int, char**) {
+ static_assert((std::is_same<std::thread::native_handle_type, pthread_t>::value), "");
return 0;
}
diff --git a/libcxx/test/libcxx-03/type_traits/convert_to_integral.pass.cpp b/libcxx/test/libcxx-03/type_traits/convert_to_integral.pass.cpp
index f1036b392..4734088d2 100644
--- a/libcxx/test/libcxx-03/type_traits/convert_to_integral.pass.cpp
+++ b/libcxx/test/libcxx-03/type_traits/convert_to_integral.pass.cpp
@@ -28,63 +28,54 @@ TEST_CLANG_DIAGNOSTIC_IGNORED("-Wprivate-header")
#include "user_defined_integral.h"
template <class T>
-struct EnumType
-{
- enum type : T {E_zero, E_one};
+struct EnumType {
+ enum type : T { E_zero, E_one };
};
-
template <class From, class To>
-void check_integral_types()
-{
+void check_integral_types() {
typedef std::numeric_limits<From> Limits;
const From max = Limits::max();
const From min = Limits::min();
{
- auto ret = std::__convert_to_integral((From)max);
- assert(ret == max);
- ret = std::__convert_to_integral((From)min);
- assert(ret == min);
- static_assert(std::is_same<decltype(ret), To>::value, "");
+ auto ret = std::__convert_to_integral((From)max);
+ assert(ret == max);
+ ret = std::__convert_to_integral((From)min);
+ assert(ret == min);
+ static_assert(std::is_same<decltype(ret), To>::value, "");
}
{
- UserDefinedIntegral<From> f(max);
- auto ret = std::__convert_to_integral(f);
- assert(ret == max);
- f.value = min;
- ret = std::__convert_to_integral(f);
- assert(ret == min);
- static_assert(std::is_same<decltype(ret), To>::value, "");
+ UserDefinedIntegral<From> f(max);
+ auto ret = std::__convert_to_integral(f);
+ assert(ret == max);
+ f.value = min;
+ ret = std::__convert_to_integral(f);
+ assert(ret == min);
+ static_assert(std::is_same<decltype(ret), To>::value, "");
}
{
- typedef typename EnumType<From>::type Enum;
- Enum e(static_cast<Enum>(max));
- auto ret = std::__convert_to_integral(e);
- assert(ret == max);
- e = static_cast<Enum>(min);
- ret = std::__convert_to_integral(min);
- assert(ret == min);
- static_assert(std::is_same<decltype(ret), To>::value, "");
+ typedef typename EnumType<From>::type Enum;
+ Enum e(static_cast<Enum>(max));
+ auto ret = std::__convert_to_integral(e);
+ assert(ret == max);
+ e = static_cast<Enum>(min);
+ ret = std::__convert_to_integral(min);
+ assert(ret == min);
+ static_assert(std::is_same<decltype(ret), To>::value, "");
}
}
-
template <class From, class To>
-void check_enum_types()
-{
+void check_enum_types() {
auto ret = std::__convert_to_integral((From)1);
assert(ret == 1);
static_assert(std::is_same<decltype(ret), To>::value, "");
}
-
enum enum1 { zero = 0, one = 1 };
-enum enum2 : unsigned long {
- value = std::numeric_limits<unsigned long>::max()
-};
+enum enum2 : unsigned long { value = std::numeric_limits<unsigned long>::max() };
-int main(int, char**)
-{
+int main(int, char**) {
check_integral_types<bool, int>();
check_integral_types<char, int>();
check_integral_types<signed char, int>();
@@ -98,8 +89,8 @@ int main(int, char**)
// char32_t must promote to an unsigned int on these platforms [conv.prom].
// Use the following logic to make the test work on such platforms.
// (sizeof(std::uint32_t) == sizeof(unsigned int)) ? unsigned int : std::uint32_t;
- typedef std::conditional<sizeof(std::uint32_t) == sizeof(unsigned int),
- unsigned int, std::uint32_t>::type char_integral;
+ typedef std::conditional<sizeof(std::uint32_t) == sizeof(unsigned int), unsigned int, std::uint32_t>::type
+ char_integral;
check_integral_types<char32_t, char_integral>();
check_integral_types<short, int>();
check_integral_types<unsigned short, int>();
@@ -113,7 +104,7 @@ int main(int, char**)
check_integral_types<__int128_t, __int128_t>();
check_integral_types<__uint128_t, __uint128_t>();
#endif
- // TODO(ericwf): Not standard
+ // TODO(ericwf): Not standard
typedef std::underlying_type<enum1>::type Enum1UT;
check_enum_types<enum1, decltype(((Enum1UT)1) + 1)>();
typedef std::underlying_type<enum2>::type Enum2UT;
diff --git a/libcxx/test/libcxx-03/type_traits/is_callable.compile.pass.cpp b/libcxx/test/libcxx-03/type_traits/is_callable.compile.pass.cpp
index d7bd701aa..f72c4413c 100644
--- a/libcxx/test/libcxx-03/type_traits/is_callable.compile.pass.cpp
+++ b/libcxx/test/libcxx-03/type_traits/is_callable.compile.pass.cpp
@@ -25,7 +25,6 @@ struct ArgumentFunctor {
static_assert(std::__is_callable<Functor>::value, "");
static_assert(std::__is_callable<decltype(func)>::value, "");
static_assert(!std::__is_callable<NotFunctor>::value, "");
-static_assert(!std::__is_callable<NotFunctor,
- decltype(&NotFunctor::compare)>::value, "");
+static_assert(!std::__is_callable<NotFunctor, decltype(&NotFunctor::compare)>::value, "");
static_assert(std::__is_callable<ArgumentFunctor, int, int>::value, "");
static_assert(!std::__is_callable<ArgumentFunctor, int>::value, "");
diff --git a/libcxx/test/libcxx-03/type_traits/is_constant_evaluated.pass.cpp b/libcxx/test/libcxx-03/type_traits/is_constant_evaluated.pass.cpp
index a538c52a5..c3f517dd1 100644
--- a/libcxx/test/libcxx-03/type_traits/is_constant_evaluated.pass.cpp
+++ b/libcxx/test/libcxx-03/type_traits/is_constant_evaluated.pass.cpp
@@ -21,16 +21,16 @@
#include "test_macros.h"
-int main (int, char**) {
- ASSERT_SAME_TYPE(decltype(std::__libcpp_is_constant_evaluated()), bool);
- ASSERT_NOEXCEPT(std::__libcpp_is_constant_evaluated());
+int main(int, char**) {
+ ASSERT_SAME_TYPE(decltype(std::__libcpp_is_constant_evaluated()), bool);
+ ASSERT_NOEXCEPT(std::__libcpp_is_constant_evaluated());
#if !defined(_LIBCPP_CXX03_LANG)
- static_assert(std::__libcpp_is_constant_evaluated(), "");
+ static_assert(std::__libcpp_is_constant_evaluated(), "");
#endif
- bool p = std::__libcpp_is_constant_evaluated();
- assert(!p);
+ bool p = std::__libcpp_is_constant_evaluated();
+ assert(!p);
- return 0;
- }
+ return 0;
+}
diff --git a/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp b/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp
index 48460d148..89667072d 100644
--- a/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_1_2_3.pass.cpp
@@ -66,67 +66,68 @@
//==============================================================================
// MemFun03 - C++03 compatible set of test member functions.
struct MemFun03 {
- typedef void*& R;
-#define F(...) \
- R f(__VA_ARGS__) { return MethodID<R(MemFun03::*)(__VA_ARGS__)>::setUncheckedCall(); } \
- R f(__VA_ARGS__) const { return MethodID<R(MemFun03::*)(__VA_ARGS__) const>::setUncheckedCall(); } \
- R f(__VA_ARGS__) volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) volatile>::setUncheckedCall(); } \
- R f(__VA_ARGS__) const volatile { return MethodID<R(MemFun03::*)(__VA_ARGS__) const volatile>::setUncheckedCall(); }
+ typedef void*& R;
+#define F(...) \
+ R f(__VA_ARGS__) { return MethodID<R (MemFun03::*)(__VA_ARGS__)>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const { return MethodID<R (MemFun03::*)(__VA_ARGS__) const>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) volatile { return MethodID<R (MemFun03::*)(__VA_ARGS__) volatile>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const volatile { return MethodID<R (MemFun03::*)(__VA_ARGS__) const volatile>::setUncheckedCall(); }
#
- F()
- F(...)
- F(ArgType&)
- F(ArgType&, ...)
- F(ArgType&, ArgType&)
- F(ArgType&, ArgType&, ...)
- F(ArgType&, ArgType&, ArgType&)
- F(ArgType&, ArgType&, ArgType&, ...)
+ F()
+ F(...)
+ F(ArgType&)
+ F(ArgType&, ...)
+ F(ArgType&, ArgType&)
+ F(ArgType&, ArgType&, ...)
+ F(ArgType&, ArgType&, ArgType&)
+ F(ArgType&, ArgType&, ArgType&, ...)
#undef F
+
public:
- MemFun03() {}
+ MemFun03() {}
+
private:
- MemFun03(MemFun03 const&);
- MemFun03& operator=(MemFun03 const&);
+ MemFun03(MemFun03 const&);
+ MemFun03& operator=(MemFun03 const&);
};
-
#if TEST_STD_VER >= 11
//==============================================================================
// MemFun11 - C++11 reference qualified test member functions.
struct MemFun11 {
- typedef void*& R;
- typedef MemFun11 C;
-#define F(...) \
- R f(__VA_ARGS__) & { return MethodID<R(C::*)(__VA_ARGS__) &>::setUncheckedCall(); } \
- R f(__VA_ARGS__) const & { return MethodID<R(C::*)(__VA_ARGS__) const &>::setUncheckedCall(); } \
- R f(__VA_ARGS__) volatile & { return MethodID<R(C::*)(__VA_ARGS__) volatile &>::setUncheckedCall(); } \
- R f(__VA_ARGS__) const volatile & { return MethodID<R(C::*)(__VA_ARGS__) const volatile &>::setUncheckedCall(); } \
- R f(__VA_ARGS__) && { return MethodID<R(C::*)(__VA_ARGS__) &&>::setUncheckedCall(); } \
- R f(__VA_ARGS__) const && { return MethodID<R(C::*)(__VA_ARGS__) const &&>::setUncheckedCall(); } \
- R f(__VA_ARGS__) volatile && { return MethodID<R(C::*)(__VA_ARGS__) volatile &&>::setUncheckedCall(); } \
- R f(__VA_ARGS__) const volatile && { return MethodID<R(C::*)(__VA_ARGS__) const volatile &&>::setUncheckedCall(); }
+ typedef void*& R;
+ typedef MemFun11 C;
+# define F(...) \
+ R f(__VA_ARGS__) & { return MethodID<R (C::*)(__VA_ARGS__) &>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const& { return MethodID<R (C::*)(__VA_ARGS__) const&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) volatile& { return MethodID<R (C::*)(__VA_ARGS__) volatile&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const volatile& { return MethodID<R (C::*)(__VA_ARGS__) const volatile&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) && { return MethodID<R (C::*)(__VA_ARGS__) &&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const&& { return MethodID<R (C::*)(__VA_ARGS__) const&&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) volatile&& { return MethodID<R (C::*)(__VA_ARGS__) volatile&&>::setUncheckedCall(); } \
+ R f(__VA_ARGS__) const volatile&& { return MethodID<R (C::*)(__VA_ARGS__) const volatile&&>::setUncheckedCall(); }
#
- F()
- F(...)
- F(ArgType&&)
- F(ArgType&&, ...)
- F(ArgType&&, ArgType&&)
- F(ArgType&&, ArgType&&, ...)
- F(ArgType&&, ArgType&&, ArgType&&)
- F(ArgType&&, ArgType&&, ArgType&&, ...)
-#undef F
+ F()
+ F(...)
+ F(ArgType&&)
+ F(ArgType&&, ...)
+ F(ArgType&&, ArgType&&)
+ F(ArgType&&, ArgType&&, ...)
+ F(ArgType&&, ArgType&&, ArgType&&)
+ F(ArgType&&, ArgType&&, ArgType&&, ...)
+# undef F
+
public:
- MemFun11() {}
+ MemFun11() {}
+
private:
- MemFun11(MemFun11 const&);
- MemFun11& operator=(MemFun11 const&);
+ MemFun11(MemFun11 const&);
+ MemFun11& operator=(MemFun11 const&);
};
#endif // TEST_STD_VER >= 11
-
-
//==============================================================================
// TestCase - A test case for a single member function.
// ClassType - The type of the class being tested.
@@ -135,108 +136,104 @@ private:
// CV - the cv qualifiers of 'CallSig' represented as a type tag.
// RValue - The method is RValue qualified.
// ArgRValue - Call the method with RValue arguments.
-template <class ClassType, class CallSig, int Arity, class CV,
- bool RValue = false, bool ArgRValue = false>
+template <class ClassType, class CallSig, int Arity, class CV, bool RValue = false, bool ArgRValue = false>
struct TestCaseImp {
public:
-
- static void run() { TestCaseImp().doTest(); }
+ static void run() { TestCaseImp().doTest(); }
private:
- //==========================================================================
- // TEST DISPATCH
- void doTest() {
- // (Plan-2) Create test call objects.
- typedef ClassType T;
- typedef DerivedFromType<T> D;
- T obj;
- T* obj_ptr = &obj;
- D der;
- D* der_ptr = &der;
- DerefToType<T> dref;
- DerefPropType<T> dref2;
- std::reference_wrapper<T> rref(obj);
- std::reference_wrapper<D> drref(der);
-
- // (Plan-3) Dispatch based on the CV tags.
- CV tag;
- Bool<!RValue> NotRValue;
- runTestDispatch(tag, obj);
- runTestDispatch(tag, der);
- runTestDispatch(tag, dref2);
- runTestDispatchIf(NotRValue, tag, dref);
- runTestDispatchIf(NotRValue, tag, obj_ptr);
- runTestDispatchIf(NotRValue, tag, der_ptr);
+ //==========================================================================
+ // TEST DISPATCH
+ void doTest() {
+ // (Plan-2) Create test call objects.
+ typedef ClassType T;
+ typedef DerivedFromType<T> D;
+ T obj;
+ T* obj_ptr = &obj;
+ D der;
+ D* der_ptr = &der;
+ DerefToType<T> dref;
+ DerefPropType<T> dref2;
+ std::reference_wrapper<T> rref(obj);
+ std::reference_wrapper<D> drref(der);
+
+ // (Plan-3) Dispatch based on the CV tags.
+ CV tag;
+ Bool<!RValue> NotRValue;
+ runTestDispatch(tag, obj);
+ runTestDispatch(tag, der);
+ runTestDispatch(tag, dref2);
+ runTestDispatchIf(NotRValue, tag, dref);
+ runTestDispatchIf(NotRValue, tag, obj_ptr);
+ runTestDispatchIf(NotRValue, tag, der_ptr);
#if TEST_STD_VER >= 11
- runTestDispatchIf(NotRValue, tag, rref);
- runTestDispatchIf(NotRValue, tag, drref);
+ runTestDispatchIf(NotRValue, tag, rref);
+ runTestDispatchIf(NotRValue, tag, drref);
#endif
- }
-
- template <class QT, class Tp>
- void runTestDispatchIf(Bool<true>, QT q, Tp& v) {
- runTestDispatch(q, v);
- }
-
- template <class QT, class Tp>
- void runTestDispatchIf(Bool<false>, QT, Tp&) {
- }
-
- template <class Tp>
- void runTestDispatch(Q_None, Tp& v) {
- runTest(v);
- }
-
- template <class Tp>
- void runTestDispatch(Q_Const, Tp& v) {
- runTest(v);
- runTest(makeConst(v));
- }
-
- template <class Tp>
- void runTestDispatch(Q_Volatile, Tp& v) {
- runTest(v);
- runTest(makeVolatile(v));
-
- }
-
- template <class Tp>
- void runTestDispatch(Q_CV, Tp& v) {
- runTest(v);
- runTest(makeConst(v));
- runTest(makeVolatile(v));
- runTest(makeCV(v));
- }
-
- template <class T>
- void runTest(const std::reference_wrapper<T>& obj) {
- typedef Caster<Q_None, RValue> SCast;
- typedef Caster<Q_None, ArgRValue> ACast;
- typedef CallSig (ClassType::*MemPtr);
- // Delegate test to logic in invoke_helpers.h
- BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
- b.runTest( (MemPtr)&ClassType::f, obj);
- }
-
- template <class T>
- void runTest(T* obj) {
- typedef Caster<Q_None, RValue> SCast;
- typedef Caster<Q_None, ArgRValue> ACast;
- typedef CallSig (ClassType::*MemPtr);
- // Delegate test to logic in invoke_helpers.h
- BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
- b.runTest( (MemPtr)&ClassType::f, obj);
- }
-
- template <class Obj>
- void runTest(Obj& obj) {
- typedef Caster<Q_None, RValue> SCast;
- typedef Caster<Q_None, ArgRValue> ACast;
- typedef CallSig (ClassType::*MemPtr);
- // Delegate test to logic in invoke_helpers.h
- BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
- b.runTest( (MemPtr)&ClassType::f, obj);
- }
+ }
+
+ template <class QT, class Tp>
+ void runTestDispatchIf(Bool<true>, QT q, Tp& v) {
+ runTestDispatch(q, v);
+ }
+
+ template <class QT, class Tp>
+ void runTestDispatchIf(Bool<false>, QT, Tp&) {}
+
+ template <class Tp>
+ void runTestDispatch(Q_None, Tp& v) {
+ runTest(v);
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_Const, Tp& v) {
+ runTest(v);
+ runTest(makeConst(v));
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_Volatile, Tp& v) {
+ runTest(v);
+ runTest(makeVolatile(v));
+ }
+
+ template <class Tp>
+ void runTestDispatch(Q_CV, Tp& v) {
+ runTest(v);
+ runTest(makeConst(v));
+ runTest(makeVolatile(v));
+ runTest(makeCV(v));
+ }
+
+ template <class T>
+ void runTest(const std::reference_wrapper<T>& obj) {
+ typedef Caster<Q_None, RValue> SCast;
+ typedef Caster<Q_None, ArgRValue> ACast;
+ typedef CallSig(ClassType::* MemPtr);
+ // Delegate test to logic in invoke_helpers.h
+ BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+ b.runTest((MemPtr)&ClassType::f, obj);
+ }
+
+ template <class T>
+ void runTest(T* obj) {
+ typedef Caster<Q_None, RValue> SCast;
+ typedef Caster<Q_None, ArgRValue> ACast;
+ typedef CallSig(ClassType::* MemPtr);
+ // Delegate test to logic in invoke_helpers.h
+ BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+ b.runTest((MemPtr)&ClassType::f, obj);
+ }
+
+ template <class Obj>
+ void runTest(Obj& obj) {
+ typedef Caster<Q_None, RValue> SCast;
+ typedef Caster<Q_None, ArgRValue> ACast;
+ typedef CallSig(ClassType::* MemPtr);
+ // Delegate test to logic in invoke_helpers.h
+ BasicTest<MethodID<MemPtr>, Arity, SCast, ACast> b;
+ b.runTest((MemPtr)&ClassType::f, obj);
+ }
};
template <class Sig, int Arity, class CV>
@@ -248,23 +245,22 @@ struct TestCase11 : public TestCaseImp<MemFun11, Sig, Arity, CV, RValue, true> {
template <class Type>
struct ReferenceWrapper {
- using type = Type;
- Type* ptr;
+ using type = Type;
+ Type* ptr;
- static void fun(Type&) noexcept;
- static void fun(Type&&) = delete;
+ static void fun(Type&) noexcept;
+ static void fun(Type&&) = delete;
- template <class Type2,
- class = typename std::enable_if<!std::__is_same_uncvref<Type2, ReferenceWrapper>::value>::type>
- constexpr ReferenceWrapper(Type2&& t) noexcept : ptr(&t) {}
+ template <class Type2, class = typename std::enable_if<!std::__is_same_uncvref<Type2, ReferenceWrapper>::value>::type>
+ constexpr ReferenceWrapper(Type2&& t) noexcept : ptr(&t) {}
- constexpr Type& get() const noexcept { return *ptr; }
- constexpr operator Type&() const noexcept { return *ptr; }
+ constexpr Type& get() const noexcept { return *ptr; }
+ constexpr operator Type&() const noexcept { return *ptr; }
- template <class... _ArgTypes>
- constexpr std::__invoke_result_t<Type&, _ArgTypes...> operator()(_ArgTypes&&... __args) const {
- return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
- }
+ template <class... _ArgTypes>
+ constexpr std::__invoke_result_t<Type&, _ArgTypes...> operator()(_ArgTypes&&... __args) const {
+ return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
+ }
};
template <class Tp>
@@ -273,132 +269,132 @@ struct DerivedFromRefWrap : public ReferenceWrapper<Tp> {
};
TEST_CONSTEXPR_CXX14 bool test_derived_from_ref_wrap() {
- int x = 42;
- ReferenceWrapper<int> r(x);
- DerivedFromRefWrap<int> d(x);
- auto get_fn = &ReferenceWrapper<int>::get;
- auto& ret = std::__invoke(get_fn, r);
- assert(&ret == &x);
- auto& ret2 = std::__invoke(get_fn, d);
- assert(&ret2 == &x);
-
- return true;
+ int x = 42;
+ ReferenceWrapper<int> r(x);
+ DerivedFromRefWrap<int> d(x);
+ auto get_fn = &ReferenceWrapper<int>::get;
+ auto& ret = std::__invoke(get_fn, r);
+ assert(&ret == &x);
+ auto& ret2 = std::__invoke(get_fn, d);
+ assert(&ret2 == &x);
+
+ return true;
}
TEST_CONSTEXPR_CXX20 bool test_reference_wrapper_reference_wrapper() {
- int x = 42;
- auto get_fn = &std::reference_wrapper<int>::get;
- std::reference_wrapper<int> r(x);
- std::reference_wrapper<std::reference_wrapper<int>> r2(r);
- auto& ret3 = std::__invoke(get_fn, r2);
- assert(&ret3 == &x);
-
- return true;
+ int x = 42;
+ auto get_fn = &std::reference_wrapper<int>::get;
+ std::reference_wrapper<int> r(x);
+ std::reference_wrapper<std::reference_wrapper<int>> r2(r);
+ auto& ret3 = std::__invoke(get_fn, r2);
+ assert(&ret3 == &x);
+
+ return true;
}
#endif
int main(int, char**) {
- typedef void*& R;
- typedef ArgType A;
- TestCase<R(), 0, Q_None>::run();
- TestCase<R() const, 0, Q_Const>::run();
- TestCase<R() volatile, 0, Q_Volatile>::run();
- TestCase<R() const volatile, 0, Q_CV>::run();
- TestCase<R(...), 0, Q_None>::run();
- TestCase<R(...) const, 0, Q_Const>::run();
- TestCase<R(...) volatile, 0, Q_Volatile>::run();
- TestCase<R(...) const volatile, 0, Q_CV>::run();
- TestCase<R(A&), 1, Q_None>::run();
- TestCase<R(A&) const, 1, Q_Const>::run();
- TestCase<R(A&) volatile, 1, Q_Volatile>::run();
- TestCase<R(A&) const volatile, 1, Q_CV>::run();
- TestCase<R(A&, ...), 1, Q_None>::run();
- TestCase<R(A&, ...) const, 1, Q_Const>::run();
- TestCase<R(A&, ...) volatile, 1, Q_Volatile>::run();
- TestCase<R(A&, ...) const volatile, 1, Q_CV>::run();
- TestCase<R(A&, A&), 2, Q_None>::run();
- TestCase<R(A&, A&) const, 2, Q_Const>::run();
- TestCase<R(A&, A&) volatile, 2, Q_Volatile>::run();
- TestCase<R(A&, A&) const volatile, 2, Q_CV>::run();
- TestCase<R(A&, A&, ...), 2, Q_None>::run();
- TestCase<R(A&, A&, ...) const, 2, Q_Const>::run();
- TestCase<R(A&, A&, ...) volatile, 2, Q_Volatile>::run();
- TestCase<R(A&, A&, ...) const volatile, 2, Q_CV>::run();
- TestCase<R(A&, A&, A&), 3, Q_None>::run();
- TestCase<R(A&, A&, A&) const, 3, Q_Const>::run();
- TestCase<R(A&, A&, A&) volatile, 3, Q_Volatile>::run();
- TestCase<R(A&, A&, A&) const volatile, 3, Q_CV>::run();
- TestCase<R(A&, A&, A&, ...), 3, Q_None>::run();
- TestCase<R(A&, A&, A&, ...) const, 3, Q_Const>::run();
- TestCase<R(A&, A&, A&, ...) volatile, 3, Q_Volatile>::run();
- TestCase<R(A&, A&, A&, ...) const volatile, 3, Q_CV>::run();
+ typedef void*& R;
+ typedef ArgType A;
+ TestCase<R(), 0, Q_None>::run();
+ TestCase<R() const, 0, Q_Const>::run();
+ TestCase<R() volatile, 0, Q_Volatile>::run();
+ TestCase<R() const volatile, 0, Q_CV>::run();
+ TestCase<R(...), 0, Q_None>::run();
+ TestCase<R(...) const, 0, Q_Const>::run();
+ TestCase<R(...) volatile, 0, Q_Volatile>::run();
+ TestCase<R(...) const volatile, 0, Q_CV>::run();
+ TestCase<R(A&), 1, Q_None>::run();
+ TestCase<R(A&) const, 1, Q_Const>::run();
+ TestCase<R(A&) volatile, 1, Q_Volatile>::run();
+ TestCase<R(A&) const volatile, 1, Q_CV>::run();
+ TestCase<R(A&, ...), 1, Q_None>::run();
+ TestCase<R(A&, ...) const, 1, Q_Const>::run();
+ TestCase<R(A&, ...) volatile, 1, Q_Volatile>::run();
+ TestCase<R(A&, ...) const volatile, 1, Q_CV>::run();
+ TestCase<R(A&, A&), 2, Q_None>::run();
+ TestCase<R(A&, A&) const, 2, Q_Const>::run();
+ TestCase<R(A&, A&) volatile, 2, Q_Volatile>::run();
+ TestCase<R(A&, A&) const volatile, 2, Q_CV>::run();
+ TestCase<R(A&, A&, ...), 2, Q_None>::run();
+ TestCase<R(A&, A&, ...) const, 2, Q_Const>::run();
+ TestCase<R(A&, A&, ...) volatile, 2, Q_Volatile>::run();
+ TestCase<R(A&, A&, ...) const volatile, 2, Q_CV>::run();
+ TestCase<R(A&, A&, A&), 3, Q_None>::run();
+ TestCase<R(A&, A&, A&) const, 3, Q_Const>::run();
+ TestCase<R(A&, A&, A&) volatile, 3, Q_Volatile>::run();
+ TestCase<R(A&, A&, A&) const volatile, 3, Q_CV>::run();
+ TestCase<R(A&, A&, A&, ...), 3, Q_None>::run();
+ TestCase<R(A&, A&, A&, ...) const, 3, Q_Const>::run();
+ TestCase<R(A&, A&, A&, ...) volatile, 3, Q_Volatile>::run();
+ TestCase<R(A&, A&, A&, ...) const volatile, 3, Q_CV>::run();
#if TEST_STD_VER >= 11
- TestCase11<R() &, 0, Q_None>::run();
- TestCase11<R() const &, 0, Q_Const>::run();
- TestCase11<R() volatile &, 0, Q_Volatile>::run();
- TestCase11<R() const volatile &, 0, Q_CV>::run();
- TestCase11<R(...) &, 0, Q_None>::run();
- TestCase11<R(...) const &, 0, Q_Const>::run();
- TestCase11<R(...) volatile &, 0, Q_Volatile>::run();
- TestCase11<R(...) const volatile &, 0, Q_CV>::run();
- TestCase11<R(A&&) &, 1, Q_None>::run();
- TestCase11<R(A&&) const &, 1, Q_Const>::run();
- TestCase11<R(A&&) volatile &, 1, Q_Volatile>::run();
- TestCase11<R(A&&) const volatile &, 1, Q_CV>::run();
- TestCase11<R(A&&, ...) &, 1, Q_None>::run();
- TestCase11<R(A&&, ...) const &, 1, Q_Const>::run();
- TestCase11<R(A&&, ...) volatile &, 1, Q_Volatile>::run();
- TestCase11<R(A&&, ...) const volatile &, 1, Q_CV>::run();
- TestCase11<R(A&&, A&&) &, 2, Q_None>::run();
- TestCase11<R(A&&, A&&) const &, 2, Q_Const>::run();
- TestCase11<R(A&&, A&&) volatile &, 2, Q_Volatile>::run();
- TestCase11<R(A&&, A&&) const volatile &, 2, Q_CV>::run();
- TestCase11<R(A&&, A&&, ...) &, 2, Q_None>::run();
- TestCase11<R(A&&, A&&, ...) const &, 2, Q_Const>::run();
- TestCase11<R(A&&, A&&, ...) volatile &, 2, Q_Volatile>::run();
- TestCase11<R(A&&, A&&, ...) const volatile &, 2, Q_CV>::run();
- TestCase11<R() &&, 0, Q_None, /* RValue */ true>::run();
- TestCase11<R() const &&, 0, Q_Const, /* RValue */ true>::run();
- TestCase11<R() volatile &&, 0, Q_Volatile, /* RValue */ true>::run();
- TestCase11<R() const volatile &&, 0, Q_CV, /* RValue */ true>::run();
- TestCase11<R(...) &&, 0, Q_None, /* RValue */ true>::run();
- TestCase11<R(...) const &&, 0, Q_Const, /* RValue */ true>::run();
- TestCase11<R(...) volatile &&, 0, Q_Volatile, /* RValue */ true>::run();
- TestCase11<R(...) const volatile &&, 0, Q_CV, /* RValue */ true>::run();
- TestCase11<R(A&&) &&, 1, Q_None, /* RValue */ true>::run();
- TestCase11<R(A&&) const &&, 1, Q_Const, /* RValue */ true>::run();
- TestCase11<R(A&&) volatile &&, 1, Q_Volatile, /* RValue */ true>::run();
- TestCase11<R(A&&) const volatile &&, 1, Q_CV, /* RValue */ true>::run();
- TestCase11<R(A&&, ...) &&, 1, Q_None, /* RValue */ true>::run();
- TestCase11<R(A&&, ...) const &&, 1, Q_Const, /* RValue */ true>::run();
- TestCase11<R(A&&, ...) volatile &&, 1, Q_Volatile, /* RValue */ true>::run();
- TestCase11<R(A&&, ...) const volatile &&, 1, Q_CV, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&) &&, 2, Q_None, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&) const &&, 2, Q_Const, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&) volatile &&, 2, Q_Volatile, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&) const volatile &&, 2, Q_CV, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, ...) &&, 2, Q_None, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, ...) const &&, 2, Q_Const, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, ...) volatile &&, 2, Q_Volatile, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, ...) const volatile &&, 2, Q_CV, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, A&&) &&, 3, Q_None, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, A&&) const &&, 3, Q_Const, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, A&&) volatile &&, 3, Q_Volatile, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, A&&) const volatile &&, 3, Q_CV, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, A&&, ...) &&, 3, Q_None, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, A&&, ...) const &&, 3, Q_Const, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, A&&, ...) volatile &&, 3, Q_Volatile, /* RValue */ true>::run();
- TestCase11<R(A&&, A&&, A&&, ...) const volatile &&, 3, Q_CV, /* RValue */ true>::run();
-
- test_derived_from_ref_wrap();
- test_reference_wrapper_reference_wrapper();
-#if TEST_STD_VER > 11
- static_assert(test_derived_from_ref_wrap(), "");
-#endif
-#if TEST_STD_VER > 17
- static_assert(test_reference_wrapper_reference_wrapper(), "");
-#endif
+ TestCase11<R() &, 0, Q_None>::run();
+ TestCase11<R() const&, 0, Q_Const>::run();
+ TestCase11<R() volatile&, 0, Q_Volatile>::run();
+ TestCase11<R() const volatile&, 0, Q_CV>::run();
+ TestCase11<R(...) &, 0, Q_None>::run();
+ TestCase11<R(...) const&, 0, Q_Const>::run();
+ TestCase11<R(...) volatile&, 0, Q_Volatile>::run();
+ TestCase11<R(...) const volatile&, 0, Q_CV>::run();
+ TestCase11<R(A&&) &, 1, Q_None>::run();
+ TestCase11<R(A&&) const&, 1, Q_Const>::run();
+ TestCase11<R(A&&) volatile&, 1, Q_Volatile>::run();
+ TestCase11<R(A&&) const volatile&, 1, Q_CV>::run();
+ TestCase11<R(A&&, ...) &, 1, Q_None>::run();
+ TestCase11<R(A&&, ...) const&, 1, Q_Const>::run();
+ TestCase11<R(A&&, ...) volatile&, 1, Q_Volatile>::run();
+ TestCase11<R(A&&, ...) const volatile&, 1, Q_CV>::run();
+ TestCase11<R(A&&, A&&) &, 2, Q_None>::run();
+ TestCase11<R(A&&, A&&) const&, 2, Q_Const>::run();
+ TestCase11<R(A&&, A&&) volatile&, 2, Q_Volatile>::run();
+ TestCase11<R(A&&, A&&) const volatile&, 2, Q_CV>::run();
+ TestCase11<R(A&&, A&&, ...) &, 2, Q_None>::run();
+ TestCase11<R(A&&, A&&, ...) const&, 2, Q_Const>::run();
+ TestCase11<R(A&&, A&&, ...) volatile&, 2, Q_Volatile>::run();
+ TestCase11<R(A&&, A&&, ...) const volatile&, 2, Q_CV>::run();
+ TestCase11<R() &&, 0, Q_None, /* RValue */ true>::run();
+ TestCase11<R() const&&, 0, Q_Const, /* RValue */ true>::run();
+ TestCase11<R() volatile&&, 0, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R() const volatile&&, 0, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(...) &&, 0, Q_None, /* RValue */ true>::run();
+ TestCase11<R(...) const&&, 0, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(...) volatile&&, 0, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(...) const volatile&&, 0, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&) &&, 1, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&) const&&, 1, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&) volatile&&, 1, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&) const volatile&&, 1, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) &&, 1, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) const&&, 1, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) volatile&&, 1, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, ...) const volatile&&, 1, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) &&, 2, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) const&&, 2, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) volatile&&, 2, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&) const volatile&&, 2, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) &&, 2, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) const&&, 2, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) volatile&&, 2, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, ...) const volatile&&, 2, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) &&, 3, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) const&&, 3, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) volatile&&, 3, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&) const volatile&&, 3, Q_CV, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) &&, 3, Q_None, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) const&&, 3, Q_Const, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) volatile&&, 3, Q_Volatile, /* RValue */ true>::run();
+ TestCase11<R(A&&, A&&, A&&, ...) const volatile&&, 3, Q_CV, /* RValue */ true>::run();
+
+ test_derived_from_ref_wrap();
+ test_reference_wrapper_reference_wrapper();
+# if TEST_STD_VER > 11
+ static_assert(test_derived_from_ref_wrap(), "");
+# endif
+# if TEST_STD_VER > 17
+ static_assert(test_reference_wrapper_reference_wrapper(), "");
+# endif
#endif // TEST_STD_VER >= 11
return 0;
diff --git a/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp b/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
index 0df592908..7e5c18754 100644
--- a/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_4_5_6.pass.cpp
@@ -47,164 +47,160 @@
template <class Tp>
struct TestMemberObject {
- TestMemberObject() : object() {}
- Tp object;
+ TestMemberObject() : object() {}
+ Tp object;
+
private:
- TestMemberObject(TestMemberObject const&);
- TestMemberObject& operator=(TestMemberObject const&);
+ TestMemberObject(TestMemberObject const&);
+ TestMemberObject& operator=(TestMemberObject const&);
};
template <class ObjectType>
struct TestCase {
- public:
-
- static void run() { TestCase().doTest(); }
+public:
+ static void run() { TestCase().doTest(); }
private:
- typedef TestMemberObject<ObjectType> TestType;
-
- //==========================================================================
- // TEST DISPATCH
- void doTest() {
- typedef DerivedFromType<TestType> Derived;
- TestType obj;
- TestType* obj_ptr = &obj;
- Derived der;
- Derived* der_ptr = &der;
- DerefToType<TestType> dref;
- DerefPropType<TestType> dref2;
- std::reference_wrapper<TestType> rref(obj);
- std::reference_wrapper<Derived> drref(der);
-
- {
- typedef ObjectType (TestType::*MemPtr);
- typedef ObjectType E;
- MemPtr M = &TestType::object;
- runTestDispatch<E>(M, obj, &obj.object);
- runTestDispatch<E>(M, der, &der.object);
- runTestDispatch<E>(M, dref2, &dref2.object.object);
- runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
- runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+ typedef TestMemberObject<ObjectType> TestType;
+
+ //==========================================================================
+ // TEST DISPATCH
+ void doTest() {
+ typedef DerivedFromType<TestType> Derived;
+ TestType obj;
+ TestType* obj_ptr = &obj;
+ Derived der;
+ Derived* der_ptr = &der;
+ DerefToType<TestType> dref;
+ DerefPropType<TestType> dref2;
+ std::reference_wrapper<TestType> rref(obj);
+ std::reference_wrapper<Derived> drref(der);
+
+ {
+ typedef ObjectType(TestType::* MemPtr);
+ typedef ObjectType E;
+ MemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
#if TEST_STD_VER >= 11
- runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
- runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+ runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+ runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
#endif
- runTestNoPropDispatch<E>(M, dref, &dref.object.object);
- }
- {
- typedef ObjectType const (TestType::*CMemPtr);
- typedef ObjectType const E;
- CMemPtr M = &TestType::object;
- runTestDispatch<E>(M, obj, &obj.object);
- runTestDispatch<E>(M, der, &der.object);
- runTestDispatch<E>(M, dref2, &dref2.object.object);
- runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
- runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+ runTestNoPropDispatch<E>(M, dref, &dref.object.object);
+ }
+ {
+ typedef ObjectType const(TestType::* CMemPtr);
+ typedef ObjectType const E;
+ CMemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
#if TEST_STD_VER >= 11
- runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
- runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+ runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+ runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
#endif
- runTestNoPropDispatch<E>(M, dref, &dref.object.object);
- }
- {
- typedef ObjectType volatile (TestType::*VMemPtr);
- typedef ObjectType volatile E;
- VMemPtr M = &TestType::object;
- runTestDispatch<E>(M, obj, &obj.object);
- runTestDispatch<E>(M, der, &der.object);
- runTestDispatch<E>(M, dref2, &dref2.object.object);
- runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
- runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+ runTestNoPropDispatch<E>(M, dref, &dref.object.object);
+ }
+ {
+ typedef ObjectType volatile(TestType::* VMemPtr);
+ typedef ObjectType volatile E;
+ VMemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
#if TEST_STD_VER >= 11
- runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
- runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+ runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+ runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
#endif
- runTestNoPropDispatch<E>(M, dref, &dref.object.object);
- }
- {
- typedef ObjectType const volatile (TestType::*CVMemPtr);
- typedef ObjectType const volatile E;
- CVMemPtr M = &TestType::object;
- runTestDispatch<E>(M, obj, &obj.object);
- runTestDispatch<E>(M, der, &der.object);
- runTestDispatch<E>(M, dref2, &dref2.object.object);
- runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
- runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
+ runTestNoPropDispatch<E>(M, dref, &dref.object.object);
+ }
+ {
+ typedef ObjectType const volatile(TestType::* CVMemPtr);
+ typedef ObjectType const volatile E;
+ CVMemPtr M = &TestType::object;
+ runTestDispatch<E>(M, obj, &obj.object);
+ runTestDispatch<E>(M, der, &der.object);
+ runTestDispatch<E>(M, dref2, &dref2.object.object);
+ runTestPropCVDispatch<E>(M, obj_ptr, &obj_ptr->object);
+ runTestPropCVDispatch<E>(M, der_ptr, &der_ptr->object);
#if TEST_STD_VER >= 11
- runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
- runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
+ runTestPropCVDispatch<E>(M, rref, &(rref.get().object));
+ runTestPropCVDispatch<E>(M, drref, &(drref.get().object));
#endif
- runTestNoPropDispatch<E>(M, dref, &dref.object.object);
- }
+ runTestNoPropDispatch<E>(M, dref, &dref.object.object);
}
-
- template <class Expect, class Fn, class T>
- void runTestDispatch(Fn M, T& obj, ObjectType* expect) {
- runTest<Expect &> (M, C_<T&>(obj), expect);
- runTest<Expect const&> (M, C_<T const&>(obj), expect);
- runTest<Expect volatile&> (M, C_<T volatile&>(obj), expect);
- runTest<Expect const volatile&>(M, C_<T const volatile&>(obj), expect);
+ }
+
+ template <class Expect, class Fn, class T>
+ void runTestDispatch(Fn M, T& obj, ObjectType* expect) {
+ runTest<Expect&>(M, C_<T&>(obj), expect);
+ runTest<Expect const&>(M, C_<T const&>(obj), expect);
+ runTest<Expect volatile&>(M, C_<T volatile&>(obj), expect);
+ runTest<Expect const volatile&>(M, C_<T const volatile&>(obj), expect);
#if TEST_STD_VER >= 11
- runTest<Expect&&> (M, C_<T&&>(obj), expect);
- runTest<Expect const&&> (M, C_<T const&&>(obj), expect);
- runTest<Expect volatile&&> (M, C_<T volatile&&>(obj), expect);
- runTest<Expect const volatile&&>(M, C_<T const volatile&&>(obj), expect);
+ runTest<Expect&&>(M, C_<T&&>(obj), expect);
+ runTest<Expect const&&>(M, C_<T const&&>(obj), expect);
+ runTest<Expect volatile&&>(M, C_<T volatile&&>(obj), expect);
+ runTest<Expect const volatile&&>(M, C_<T const volatile&&>(obj), expect);
#endif
- }
-
- template <class Expect, class Fn, class T>
- void runTestPropCVDispatch(Fn M, T& obj, ObjectType* expect) {
- runTest<Expect &> (M, obj, expect);
- runTest<Expect const&> (M, makeConst(obj), expect);
- runTest<Expect volatile&> (M, makeVolatile(obj), expect);
- runTest<Expect const volatile&>(M, makeCV(obj), expect);
- }
-
- template <class Expect, class Fn, class T>
- void runTestNoPropDispatch(Fn M, T& obj, ObjectType* expect) {
- runTest<Expect&>(M, C_<T &>(obj), expect);
- runTest<Expect&>(M, C_<T const&>(obj), expect);
- runTest<Expect&>(M, C_<T volatile&>(obj), expect);
- runTest<Expect&>(M, C_<T const volatile&>(obj), expect);
+ }
+
+ template <class Expect, class Fn, class T>
+ void runTestPropCVDispatch(Fn M, T& obj, ObjectType* expect) {
+ runTest<Expect&>(M, obj, expect);
+ runTest<Expect const&>(M, makeConst(obj), expect);
+ runTest<Expect volatile&>(M, makeVolatile(obj), expect);
+ runTest<Expect const volatile&>(M, makeCV(obj), expect);
+ }
+
+ template <class Expect, class Fn, class T>
+ void runTestNoPropDispatch(Fn M, T& obj, ObjectType* expect) {
+ runTest<Expect&>(M, C_<T&>(obj), expect);
+ runTest<Expect&>(M, C_<T const&>(obj), expect);
+ runTest<Expect&>(M, C_<T volatile&>(obj), expect);
+ runTest<Expect&>(M, C_<T const volatile&>(obj), expect);
#if TEST_STD_VER >= 11
- runTest<Expect&>(M, C_<T&&>(obj), expect);
- runTest<Expect&>(M, C_<T const&&>(obj), expect);
- runTest<Expect&>(M, C_<T volatile&&>(obj), expect);
- runTest<Expect&>(M, C_<T const volatile&&>(obj), expect);
+ runTest<Expect&>(M, C_<T&&>(obj), expect);
+ runTest<Expect&>(M, C_<T const&&>(obj), expect);
+ runTest<Expect&>(M, C_<T volatile&&>(obj), expect);
+ runTest<Expect&>(M, C_<T const volatile&&>(obj), expect);
#endif
- }
+ }
- template <class Expect, class Fn, class T>
- void runTest(Fn M, const T& obj, ObjectType* expect) {
- static_assert((std::is_same<
- decltype(std::__invoke(M, obj)), Expect
- >::value), "");
- Expect e = std::__invoke(M, obj);
- assert(&e == expect);
- }
+ template <class Expect, class Fn, class T>
+ void runTest(Fn M, const T& obj, ObjectType* expect) {
+ static_assert((std::is_same< decltype(std::__invoke(M, obj)), Expect >::value), "");
+ Expect e = std::__invoke(M, obj);
+ assert(&e == expect);
+ }
- template <class Expect, class Fn, class T>
+ template <class Expect, class Fn, class T>
#if TEST_STD_VER >= 11
- void runTest(Fn M, T&& obj, ObjectType* expect) {
+ void runTest(Fn M, T&& obj, ObjectType* expect){
#else
- void runTest(Fn M, T& obj, ObjectType* expect ) {
+ void runTest(Fn M, T& obj, ObjectType* expect) {
#endif
- {
- static_assert((std::is_same<
- decltype(std::__invoke(M, std::forward<T>(obj))), Expect
- >::value), "");
- Expect e = std::__invoke(M, std::forward<T>(obj));
- assert(&e == expect);
- }
- }
-};
+ {static_assert((std::is_same< decltype(std::__invoke(M, std::forward<T>(obj))), Expect >::value), "");
+ Expect e = std::__invoke(M, std::forward<T>(obj));
+ assert(&e == expect);
+}
+}
+}
+;
int main(int, char**) {
- TestCase<ArgType>::run();
- TestCase<ArgType const>::run();
- TestCase<ArgType volatile>::run();
- TestCase<ArgType const volatile>::run();
- TestCase<ArgType*>::run();
+ TestCase<ArgType>::run();
+ TestCase<ArgType const>::run();
+ TestCase<ArgType volatile>::run();
+ TestCase<ArgType const volatile>::run();
+ TestCase<ArgType*>::run();
return 0;
}
diff --git a/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_7.pass.cpp b/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_7.pass.cpp
index fb789fa0a..f1e7d10aa 100644
--- a/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_7.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/function.objects/func.require/bullet_7.pass.cpp
@@ -39,8 +39,6 @@
// 'f' has been called using 'FunctionID::checkCall()' if 'f' is a free
// function and 'MethodID::checkCall()' otherwise.
-
-
#include <functional>
#include <type_traits>
#include <cassert>
@@ -48,116 +46,113 @@
#include "test_macros.h"
#include "invoke_helpers.h"
-
//==============================================================================
// freeFunction03 - A C++03 free function.
-void*& freeFunction03() {
- return FunctionPtrID<void*&(), freeFunction03>::setUncheckedCall();
-}
+void*& freeFunction03() { return FunctionPtrID<void*&(), freeFunction03>::setUncheckedCall(); }
-void*& freeFunction03(...) {
- return FunctionPtrID<void*&(...), freeFunction03>::setUncheckedCall();
-}
+void*& freeFunction03(...) { return FunctionPtrID<void*&(...), freeFunction03>::setUncheckedCall(); }
template <class A0>
void*& freeFunction03(A0&) {
- return FunctionPtrID<void*&(A0&), freeFunction03>::setUncheckedCall();
+ return FunctionPtrID<void*&(A0&), freeFunction03>::setUncheckedCall();
}
-
template <class A0>
void*& freeFunction03(A0&, ...) {
- return FunctionPtrID<void*&(A0&, ...), freeFunction03>::setUncheckedCall();
+ return FunctionPtrID<void*&(A0&, ...), freeFunction03>::setUncheckedCall();
}
template <class A0, class A1>
void*& freeFunction03(A0&, A1&) {
- return FunctionPtrID<void*&(A0&, A1&), freeFunction03>::setUncheckedCall();
+ return FunctionPtrID<void*&(A0&, A1&), freeFunction03>::setUncheckedCall();
}
-
template <class A0, class A1>
void*& freeFunction03(A0&, A1&, ...) {
- return FunctionPtrID<void*&(A0&, A1&, ...), freeFunction03>::setUncheckedCall();
+ return FunctionPtrID<void*&(A0&, A1&, ...), freeFunction03>::setUncheckedCall();
}
template <class A0, class A1, class A2>
void*& freeFunction03(A0&, A1&, A2&) {
- return FunctionPtrID<void*&(A0&, A1&, A2&), freeFunction03>::setUncheckedCall();
+ return FunctionPtrID<void*&(A0&, A1&, A2&), freeFunction03>::setUncheckedCall();
}
template <class A0, class A1, class A2>
void*& freeFunction03(A0&, A1&, A2&, ...) {
- return FunctionPtrID<void*&(A0&, A1&, A2&, ...), freeFunction03>::setUncheckedCall();
+ return FunctionPtrID<void*&(A0&, A1&, A2&, ...), freeFunction03>::setUncheckedCall();
}
//==============================================================================
// Functor03 - C++03 compatible functor object
struct Functor03 {
- typedef void*& R;
- typedef Functor03 C;
-#define F(Args, ...) \
- __VA_ARGS__ R operator() Args { return MethodID<R(C::*) Args>::setUncheckedCall(); } \
- __VA_ARGS__ R operator() Args const { return MethodID<R(C::*) Args const>::setUncheckedCall(); } \
- __VA_ARGS__ R operator() Args volatile { return MethodID<R(C::*) Args volatile>::setUncheckedCall(); } \
- __VA_ARGS__ R operator() Args const volatile { return MethodID<R(C::*) Args const volatile>::setUncheckedCall(); }
+ typedef void*& R;
+ typedef Functor03 C;
+#define F(Args, ...) \
+ __VA_ARGS__ R operator() Args { return MethodID<R(C::*) Args>::setUncheckedCall(); } \
+ __VA_ARGS__ R operator() Args const { return MethodID<R(C::*) Args const>::setUncheckedCall(); } \
+ __VA_ARGS__ R operator() Args volatile { return MethodID<R(C::*) Args volatile>::setUncheckedCall(); } \
+ __VA_ARGS__ R operator() Args const volatile { return MethodID<R(C::*) Args const volatile>::setUncheckedCall(); }
#
- F(())
- F((A0&), template <class A0>)
- F((A0&, A1&), template <class A0, class A1>)
- F((A0&, A1&, A2&), template <class A0, class A1, class A2>)
+ F(())
+ F((A0&), template <class A0>)
+ F((A0&, A1&), template <class A0, class A1>)
+ F((A0&, A1&, A2&), template <class A0, class A1, class A2>)
#undef F
+
public:
- Functor03() {}
+ Functor03() {}
+
private:
- Functor03(Functor03 const&);
- Functor03& operator=(Functor03 const&);
+ Functor03(Functor03 const&);
+ Functor03& operator=(Functor03 const&);
};
-
#if TEST_STD_VER >= 11
//==============================================================================
// freeFunction11 - A C++11 free function.
-template <class ...Args>
+template <class... Args>
void*& freeFunction11(Args&&...) {
- return FunctionPtrID<void*&(Args&&...), freeFunction11>::setUncheckedCall();
+ return FunctionPtrID<void*&(Args && ...), freeFunction11>::setUncheckedCall();
}
-template <class ...Args>
-void*& freeFunction11(Args&&...,...) {
- return FunctionPtrID<void*&(Args&&...,...), freeFunction11>::setUncheckedCall();
+template <class... Args>
+void*& freeFunction11(Args&&..., ...) {
+ return FunctionPtrID<void*&(Args && ..., ...), freeFunction11>::setUncheckedCall();
}
//==============================================================================
// Functor11 - C++11 reference qualified test member functions.
struct Functor11 {
- typedef void*& R;
- typedef Functor11 C;
+ typedef void*& R;
+ typedef Functor11 C;
-#define F(CV) \
- template <class ...Args> \
- R operator()(Args&&...) CV { return MethodID<R(C::*)(Args&&...) CV>::setUncheckedCall(); }
+# define F(CV) \
+ template <class... Args> \
+ R operator()(Args&&...) CV { \
+ return MethodID<R (C::*)(Args && ...) CV>::setUncheckedCall(); \
+ }
#
- F(&)
- F(const &)
- F(volatile &)
- F(const volatile &)
- F(&&)
- F(const &&)
- F(volatile &&)
- F(const volatile &&)
-#undef F
+ F(&)
+ F(const&)
+ F(volatile&)
+ F(const volatile&)
+ F(&&)
+ F(const&&)
+ F(volatile&&)
+ F(const volatile&&)
+# undef F
+
public:
- Functor11() {}
+ Functor11() {}
+
private:
- Functor11(Functor11 const&);
- Functor11& operator=(Functor11 const&);
+ Functor11(Functor11 const&);
+ Functor11& operator=(Functor11 const&);
};
#endif // TEST_STD_VER >= 11
-
//==============================================================================
// TestCaseFunctorImp - A test case for an operator() class method.
// ClassType - The type of the call object.
@@ -165,20 +160,19 @@ private:
// Arity - the arity of 'CallSig'
// ObjCaster - Transformation function applied to call object.
// ArgCaster - Transformation function applied to the extra arguments.
-template <class ClassType, class CallSig, int Arity,
- class ObjCaster, class ArgCaster = LValueCaster>
+template <class ClassType, class CallSig, int Arity, class ObjCaster, class ArgCaster = LValueCaster>
struct TestCaseFunctorImp {
public:
- static void run() {
- typedef MethodID<CallSig ClassType::*> MID;
- BasicTest<MID, Arity, ObjCaster, ArgCaster> t;
- typedef ClassType T;
- typedef DerivedFromType<T> D;
- T obj;
- D der;
- t.runTest(obj);
- t.runTest(der);
- }
+ static void run() {
+ typedef MethodID<CallSig ClassType::*> MID;
+ BasicTest<MID, Arity, ObjCaster, ArgCaster> t;
+ typedef ClassType T;
+ typedef DerivedFromType<T> D;
+ T obj;
+ D der;
+ t.runTest(obj);
+ t.runTest(der);
+ }
};
//==============================================================================
@@ -190,18 +184,18 @@ public:
template <class CallSig, CallSig* FnPtr, int Arity, class ArgCaster>
struct TestCaseFreeFunction {
public:
- static void run() {
- typedef FunctionPtrID<CallSig, FnPtr> FID;
- BasicTest<FID, Arity, LValueCaster, ArgCaster> t;
-
- DerefToType<CallSig*> deref_to(FnPtr);
- DerefToType<CallSig&> deref_to_ref(*FnPtr);
-
- t.runTest(FnPtr);
- t.runTest(*FnPtr);
- t.runTest(deref_to);
- t.runTest(deref_to_ref);
- }
+ static void run() {
+ typedef FunctionPtrID<CallSig, FnPtr> FID;
+ BasicTest<FID, Arity, LValueCaster, ArgCaster> t;
+
+ DerefToType<CallSig*> deref_to(FnPtr);
+ DerefToType<CallSig&> deref_to_ref(*FnPtr);
+
+ t.runTest(FnPtr);
+ t.runTest(*FnPtr);
+ t.runTest(deref_to);
+ t.runTest(deref_to_ref);
+ }
};
//==============================================================================
@@ -210,118 +204,118 @@ public:
#if TEST_STD_VER >= 11
template <class Sig, int Arity, class ArgCaster>
void runFunctionTestCase11() {
- TestCaseFreeFunction<Sig, freeFunction11, Arity, ArgCaster>();
+ TestCaseFreeFunction<Sig, freeFunction11, Arity, ArgCaster>();
}
#endif
template <class Sig, int Arity, class ArgCaster>
void runFunctionTestCase() {
- TestCaseFreeFunction<Sig, freeFunction03, Arity, ArgCaster>();
+ TestCaseFreeFunction<Sig, freeFunction03, Arity, ArgCaster>();
#if TEST_STD_VER >= 11
- runFunctionTestCase11<Sig, Arity, ArgCaster>();
+ runFunctionTestCase11<Sig, Arity, ArgCaster>();
#endif
}
template <class Sig, int Arity, class ObjCaster, class ArgCaster>
void runFunctorTestCase() {
- TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster, ArgCaster>::run();
+ TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster, ArgCaster>::run();
}
template <class Sig, int Arity, class ObjCaster>
void runFunctorTestCase() {
- TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster>::run();
+ TestCaseFunctorImp<Functor03, Sig, Arity, ObjCaster>::run();
}
#if TEST_STD_VER >= 11
// runTestCase - Run a test case for C++11 class functor types
template <class Sig, int Arity, class ObjCaster, class ArgCaster = LValueCaster>
void runFunctorTestCase11() {
- TestCaseFunctorImp<Functor11, Sig, Arity, ObjCaster, ArgCaster>::run();
+ TestCaseFunctorImp<Functor11, Sig, Arity, ObjCaster, ArgCaster>::run();
}
#endif
// runTestCase - Run a test case for both function and functor types.
template <class Sig, int Arity, class ArgCaster>
void runTestCase() {
- runFunctionTestCase<Sig, Arity, ArgCaster>();
- runFunctorTestCase <Sig, Arity, LValueCaster, ArgCaster>();
+ runFunctionTestCase<Sig, Arity, ArgCaster>();
+ runFunctorTestCase<Sig, Arity, LValueCaster, ArgCaster>();
};
int main(int, char**) {
- typedef void*& R;
- typedef ArgType A;
- typedef A const CA;
-
- runTestCase< R(), 0, LValueCaster >();
- runTestCase< R(A&), 1, LValueCaster >();
- runTestCase< R(A&, A&), 2, LValueCaster >();
- runTestCase< R(A&, A&, A&), 3, LValueCaster >();
- runTestCase< R(CA&), 1, ConstCaster >();
- runTestCase< R(CA&, CA&), 2, ConstCaster >();
- runTestCase< R(CA&, CA&, CA&), 3, ConstCaster >();
-
- runFunctionTestCase<R(...), 0, LValueCaster >();
- runFunctionTestCase<R(A&, ...), 1, LValueCaster >();
- runFunctionTestCase<R(A&, A&, ...), 2, LValueCaster >();
- runFunctionTestCase<R(A&, A&, A&, ...), 3, LValueCaster >();
+ typedef void*& R;
+ typedef ArgType A;
+ typedef A const CA;
+
+ runTestCase< R(), 0, LValueCaster >();
+ runTestCase< R(A&), 1, LValueCaster >();
+ runTestCase< R(A&, A&), 2, LValueCaster >();
+ runTestCase< R(A&, A&, A&), 3, LValueCaster >();
+ runTestCase< R(CA&), 1, ConstCaster >();
+ runTestCase< R(CA&, CA&), 2, ConstCaster >();
+ runTestCase< R(CA&, CA&, CA&), 3, ConstCaster >();
+
+ runFunctionTestCase<R(...), 0, LValueCaster >();
+ runFunctionTestCase<R(A&, ...), 1, LValueCaster >();
+ runFunctionTestCase<R(A&, A&, ...), 2, LValueCaster >();
+ runFunctionTestCase<R(A&, A&, A&, ...), 3, LValueCaster >();
#if TEST_STD_VER >= 11
- runFunctionTestCase11<R(A&&), 1, MoveCaster >();
- runFunctionTestCase11<R(A&&, ...), 1, MoveCaster >();
+ runFunctionTestCase11<R(A&&), 1, MoveCaster >();
+ runFunctionTestCase11<R(A&&, ...), 1, MoveCaster >();
#endif
- runFunctorTestCase<R(), 0, LValueCaster >();
- runFunctorTestCase<R() const, 0, ConstCaster >();
- runFunctorTestCase<R() volatile, 0, VolatileCaster >();
- runFunctorTestCase<R() const volatile, 0, CVCaster >();
- runFunctorTestCase<R(A&), 1, LValueCaster >();
- runFunctorTestCase<R(A&) const, 1, ConstCaster >();
- runFunctorTestCase<R(A&) volatile, 1, VolatileCaster >();
- runFunctorTestCase<R(A&) const volatile, 1, CVCaster >();
- runFunctorTestCase<R(A&, A&), 2, LValueCaster >();
- runFunctorTestCase<R(A&, A&) const, 2, ConstCaster >();
- runFunctorTestCase<R(A&, A&) volatile, 2, VolatileCaster >();
- runFunctorTestCase<R(A&, A&) const volatile, 2, CVCaster >();
- runFunctorTestCase<R(A&, A&, A&), 3, LValueCaster >();
- runFunctorTestCase<R(A&, A&, A&) const, 3, ConstCaster >();
- runFunctorTestCase<R(A&, A&, A&) volatile, 3, VolatileCaster >();
- runFunctorTestCase<R(A&, A&, A&) const volatile, 3, CVCaster >();
- {
+ runFunctorTestCase<R(), 0, LValueCaster >();
+ runFunctorTestCase<R() const, 0, ConstCaster >();
+ runFunctorTestCase<R() volatile, 0, VolatileCaster >();
+ runFunctorTestCase<R() const volatile, 0, CVCaster >();
+ runFunctorTestCase<R(A&), 1, LValueCaster >();
+ runFunctorTestCase<R(A&) const, 1, ConstCaster >();
+ runFunctorTestCase<R(A&) volatile, 1, VolatileCaster >();
+ runFunctorTestCase<R(A&) const volatile, 1, CVCaster >();
+ runFunctorTestCase<R(A&, A&), 2, LValueCaster >();
+ runFunctorTestCase<R(A&, A&) const, 2, ConstCaster >();
+ runFunctorTestCase<R(A&, A&) volatile, 2, VolatileCaster >();
+ runFunctorTestCase<R(A&, A&) const volatile, 2, CVCaster >();
+ runFunctorTestCase<R(A&, A&, A&), 3, LValueCaster >();
+ runFunctorTestCase<R(A&, A&, A&) const, 3, ConstCaster >();
+ runFunctorTestCase<R(A&, A&, A&) volatile, 3, VolatileCaster >();
+ runFunctorTestCase<R(A&, A&, A&) const volatile, 3, CVCaster >();
+ {
typedef ConstCaster CC;
- runFunctorTestCase<R(CA&), 1, LValueCaster, CC>();
- runFunctorTestCase<R(CA&) const, 1, ConstCaster, CC>();
- runFunctorTestCase<R(CA&) volatile, 1, VolatileCaster, CC>();
- runFunctorTestCase<R(CA&) const volatile, 1, CVCaster, CC>();
- runFunctorTestCase<R(CA&, CA&), 2, LValueCaster, CC>();
- runFunctorTestCase<R(CA&, CA&) const, 2, ConstCaster, CC>();
- runFunctorTestCase<R(CA&, CA&) volatile, 2, VolatileCaster, CC>();
- runFunctorTestCase<R(CA&, CA&) const volatile, 2, CVCaster, CC>();
- runFunctorTestCase<R(CA&, CA&, CA&), 3, LValueCaster, CC>();
- runFunctorTestCase<R(CA&, CA&, CA&) const, 3, ConstCaster, CC>();
- runFunctorTestCase<R(CA&, CA&, CA&) volatile, 3, VolatileCaster, CC>();
- runFunctorTestCase<R(CA&, CA&, CA&) const volatile, 3, CVCaster, CC>();
- }
+ runFunctorTestCase<R(CA&), 1, LValueCaster, CC>();
+ runFunctorTestCase<R(CA&) const, 1, ConstCaster, CC>();
+ runFunctorTestCase<R(CA&) volatile, 1, VolatileCaster, CC>();
+ runFunctorTestCase<R(CA&) const volatile, 1, CVCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&), 2, LValueCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&) const, 2, ConstCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&) volatile, 2, VolatileCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&) const volatile, 2, CVCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&), 3, LValueCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&) const, 3, ConstCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&) volatile, 3, VolatileCaster, CC>();
+ runFunctorTestCase<R(CA&, CA&, CA&) const volatile, 3, CVCaster, CC>();
+ }
#if TEST_STD_VER >= 11
- runFunctorTestCase11<R() &, 0, LValueCaster >();
- runFunctorTestCase11<R() const &, 0, ConstCaster >();
- runFunctorTestCase11<R() volatile &, 0, VolatileCaster >();
- runFunctorTestCase11<R() const volatile &, 0, CVCaster >();
- runFunctorTestCase11<R() &&, 0, MoveCaster >();
- runFunctorTestCase11<R() const &&, 0, MoveConstCaster >();
- runFunctorTestCase11<R() volatile &&, 0, MoveVolatileCaster >();
- runFunctorTestCase11<R() const volatile &&, 0, MoveCVCaster >();
- {
+ runFunctorTestCase11<R() &, 0, LValueCaster >();
+ runFunctorTestCase11<R() const&, 0, ConstCaster >();
+ runFunctorTestCase11<R() volatile&, 0, VolatileCaster >();
+ runFunctorTestCase11<R() const volatile&, 0, CVCaster >();
+ runFunctorTestCase11<R() &&, 0, MoveCaster >();
+ runFunctorTestCase11<R() const&&, 0, MoveConstCaster >();
+ runFunctorTestCase11<R() volatile&&, 0, MoveVolatileCaster >();
+ runFunctorTestCase11<R() const volatile&&, 0, MoveCVCaster >();
+ {
typedef MoveCaster MC;
- runFunctorTestCase11<R(A&&) &, 1, LValueCaster, MC>();
- runFunctorTestCase11<R(A&&) const &, 1, ConstCaster, MC>();
- runFunctorTestCase11<R(A&&) volatile &, 1, VolatileCaster, MC>();
- runFunctorTestCase11<R(A&&) const volatile &, 1, CVCaster, MC>();
- runFunctorTestCase11<R(A&&) &&, 1, MoveCaster, MC>();
- runFunctorTestCase11<R(A&&) const &&, 1, MoveConstCaster, MC>();
- runFunctorTestCase11<R(A&&) volatile &&, 1, MoveVolatileCaster, MC>();
- runFunctorTestCase11<R(A&&) const volatile &&, 1, MoveCVCaster, MC>();
- }
+ runFunctorTestCase11<R(A&&) &, 1, LValueCaster, MC>();
+ runFunctorTestCase11<R(A&&) const&, 1, ConstCaster, MC>();
+ runFunctorTestCase11<R(A&&) volatile&, 1, VolatileCaster, MC>();
+ runFunctorTestCase11<R(A&&) const volatile&, 1, CVCaster, MC>();
+ runFunctorTestCase11<R(A&&) &&, 1, MoveCaster, MC>();
+ runFunctorTestCase11<R(A&&) const&&, 1, MoveConstCaster, MC>();
+ runFunctorTestCase11<R(A&&) volatile&&, 1, MoveVolatileCaster, MC>();
+ runFunctorTestCase11<R(A&&) const volatile&&, 1, MoveCVCaster, MC>();
+ }
#endif
return 0;
diff --git a/libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke.pass.cpp b/libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke.pass.cpp
index e534553a8..78349ae78 100644
--- a/libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke.pass.cpp
@@ -14,32 +14,29 @@
#include "test_macros.h"
template <typename T, int N>
-struct Array
-{
- typedef T type[N];
+struct Array {
+ typedef T type[N];
};
-struct Type
-{
- Array<char, 1>::type& f1();
- Array<char, 2>::type& f2() const;
+struct Type {
+ Array<char, 1>::type& f1();
+ Array<char, 2>::type& f2() const;
#if TEST_STD_VER >= 11
- Array<char, 1>::type& g1() &;
- Array<char, 2>::type& g2() const &;
- Array<char, 3>::type& g3() &&;
- Array<char, 4>::type& g4() const &&;
+ Array<char, 1>::type& g1() &;
+ Array<char, 2>::type& g2() const&;
+ Array<char, 3>::type& g3() &&;
+ Array<char, 4>::type& g4() const&&;
#endif
};
-int main(int, char**)
-{
- static_assert(sizeof(std::__invoke(&Type::f1, std::declval<Type >())) == 1, "");
- static_assert(sizeof(std::__invoke(&Type::f2, std::declval<Type const >())) == 2, "");
+int main(int, char**) {
+ static_assert(sizeof(std::__invoke(&Type::f1, std::declval<Type >())) == 1, "");
+ static_assert(sizeof(std::__invoke(&Type::f2, std::declval<Type const >())) == 2, "");
#if TEST_STD_VER >= 11
- static_assert(sizeof(std::__invoke(&Type::g1, std::declval<Type &>())) == 1, "");
- static_assert(sizeof(std::__invoke(&Type::g2, std::declval<Type const &>())) == 2, "");
- static_assert(sizeof(std::__invoke(&Type::g3, std::declval<Type &&>())) == 3, "");
- static_assert(sizeof(std::__invoke(&Type::g4, std::declval<Type const&&>())) == 4, "");
+ static_assert(sizeof(std::__invoke(&Type::g1, std::declval<Type&>())) == 1, "");
+ static_assert(sizeof(std::__invoke(&Type::g2, std::declval<Type const&>())) == 2, "");
+ static_assert(sizeof(std::__invoke(&Type::g3, std::declval<Type&&>())) == 3, "");
+ static_assert(sizeof(std::__invoke(&Type::g4, std::declval<Type const&&>())) == 4, "");
#endif
return 0;
diff --git a/libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke_helpers.h b/libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke_helpers.h
index f6f418b51..e4b6de4d2 100644
--- a/libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke_helpers.h
+++ b/libcxx/test/libcxx-03/utilities/function.objects/func.require/invoke_helpers.h
@@ -22,23 +22,31 @@ template <bool P>
struct Bool : public std::integral_constant<bool, P> {};
struct Q_None {
- template <class T>
- struct apply { typedef T type; };
+ template <class T>
+ struct apply {
+ typedef T type;
+ };
};
struct Q_Const {
- template <class T>
- struct apply { typedef T const type; };
+ template <class T>
+ struct apply {
+ typedef T const type;
+ };
};
struct Q_Volatile {
- template <class T>
- struct apply { typedef T volatile type; };
+ template <class T>
+ struct apply {
+ typedef T volatile type;
+ };
};
struct Q_CV {
- template <class T>
- struct apply { typedef T const volatile type; };
+ template <class T>
+ struct apply {
+ typedef T const volatile type;
+ };
};
// Caster - A functor object that performs cv-qualifier and value category
@@ -48,92 +56,103 @@ struct Q_CV {
// False otherwise.
template <class QualTag, bool RValue = false>
struct Caster {
- template <class T>
- struct apply {
- typedef typename std::remove_reference<T>::type RawType;
- typedef typename QualTag::template apply<RawType>::type CVType;
+ template <class T>
+ struct apply {
+ typedef typename std::remove_reference<T>::type RawType;
+ typedef typename QualTag::template apply<RawType>::type CVType;
#if TEST_STD_VER >= 11
- typedef typename std::conditional<RValue,
- CVType&&, CVType&
- >::type type;
+ typedef typename std::conditional<RValue, CVType&&, CVType& >::type type;
#else
- typedef CVType& type;
+ typedef CVType& type;
#endif
- };
+ };
- template <class T>
- typename apply<T>::type
- operator()(T& obj) const {
- typedef typename apply<T>::type OutType;
- return static_cast<OutType>(obj);
- }
+ template <class T>
+ typename apply<T>::type operator()(T& obj) const {
+ typedef typename apply<T>::type OutType;
+ return static_cast<OutType>(obj);
+ }
};
-typedef Caster<Q_None> LValueCaster;
-typedef Caster<Q_Const> ConstCaster;
-typedef Caster<Q_Volatile> VolatileCaster;
-typedef Caster<Q_CV> CVCaster;
-typedef Caster<Q_None, true> MoveCaster;
-typedef Caster<Q_Const, true> MoveConstCaster;
+typedef Caster<Q_None> LValueCaster;
+typedef Caster<Q_Const> ConstCaster;
+typedef Caster<Q_Volatile> VolatileCaster;
+typedef Caster<Q_CV> CVCaster;
+typedef Caster<Q_None, true> MoveCaster;
+typedef Caster<Q_Const, true> MoveConstCaster;
typedef Caster<Q_Volatile, true> MoveVolatileCaster;
-typedef Caster<Q_CV, true> MoveCVCaster;
-
+typedef Caster<Q_CV, true> MoveCVCaster;
template <class Tp>
-Tp const& makeConst(Tp& ref) { return ref; }
+Tp const& makeConst(Tp& ref) {
+ return ref;
+}
template <class Tp>
-Tp const* makeConst(Tp* ptr) { return ptr; }
+Tp const* makeConst(Tp* ptr) {
+ return ptr;
+}
template <class Tp>
std::reference_wrapper<const Tp> makeConst(std::reference_wrapper<Tp>& ref) {
- return std::reference_wrapper<const Tp>(ref.get());
+ return std::reference_wrapper<const Tp>(ref.get());
}
template <class Tp>
-Tp volatile& makeVolatile(Tp& ref) { return ref; }
+Tp volatile& makeVolatile(Tp& ref) {
+ return ref;
+}
template <class Tp>
-Tp volatile* makeVolatile(Tp* ptr) { return ptr; }
+Tp volatile* makeVolatile(Tp* ptr) {
+ return ptr;
+}
template <class Tp>
std::reference_wrapper<volatile Tp> makeVolatile(std::reference_wrapper<Tp>& ref) {
- return std::reference_wrapper<volatile Tp>(ref.get());
+ return std::reference_wrapper<volatile Tp>(ref.get());
}
template <class Tp>
-Tp const volatile& makeCV(Tp& ref) { return ref; }
+Tp const volatile& makeCV(Tp& ref) {
+ return ref;
+}
template <class Tp>
-Tp const volatile* makeCV(Tp* ptr) { return ptr; }
+Tp const volatile* makeCV(Tp* ptr) {
+ return ptr;
+}
template <class Tp>
std::reference_wrapper<const volatile Tp> makeCV(std::reference_wrapper<Tp>& ref) {
- return std::reference_wrapper<const volatile Tp>(ref.get());
+ return std::reference_wrapper<const volatile Tp>(ref.get());
}
// A shorter name for 'static_cast'
template <class QualType, class Tp>
-QualType C_(Tp& v) { return static_cast<QualType>(v); };
+QualType C_(Tp& v) {
+ return static_cast<QualType>(v);
+};
//==============================================================================
// ArgType - A non-copyable type intended to be used as a dummy argument type
// to test functions.
struct ArgType {
- int value;
- explicit ArgType(int val = 0) : value(val) {}
+ int value;
+ explicit ArgType(int val = 0) : value(val) {}
+
private:
- ArgType(ArgType const&);
- ArgType& operator=(ArgType const&);
+ ArgType(ArgType const&);
+ ArgType& operator=(ArgType const&);
};
//==============================================================================
// DerivedFromBase - A type that derives from its template argument 'Base'
template <class Base>
struct DerivedFromType : public Base {
- DerivedFromType() : Base() {}
- template <class Tp>
- explicit DerivedFromType(Tp const& t) : Base(t) {}
+ DerivedFromType() : Base() {}
+ template <class Tp>
+ explicit DerivedFromType(Tp const& t) : Base(t) {}
};
//==============================================================================
@@ -142,14 +161,14 @@ struct DerivedFromType : public Base {
// to the resulting 'To' object.
template <class To>
struct DerefToType {
- To object;
+ To object;
- DerefToType() {}
+ DerefToType() {}
- template <class Up>
- explicit DerefToType(Up const& val) : object(val) {}
+ template <class Up>
+ explicit DerefToType(Up const& val) : object(val) {}
- To& operator*() const volatile { return const_cast<To&>(object); }
+ To& operator*() const volatile { return const_cast<To&>(object); }
};
//==============================================================================
@@ -158,27 +177,27 @@ struct DerefToType {
// to the resulting 'To' object.
template <class To>
struct DerefPropType {
- To object;
+ To object;
- DerefPropType() {}
+ DerefPropType() {}
- template <class Up>
- explicit DerefPropType(Up const& val) : object(val) {}
+ template <class Up>
+ explicit DerefPropType(Up const& val) : object(val) {}
#if TEST_STD_VER < 11
- To& operator*() { return object; }
- To const& operator*() const { return object; }
- To volatile& operator*() volatile { return object; }
- To const volatile& operator*() const volatile { return object; }
+ To& operator*() { return object; }
+ To const& operator*() const { return object; }
+ To volatile& operator*() volatile { return object; }
+ To const volatile& operator*() const volatile { return object; }
#else
- To& operator*() & { return object; }
- To const& operator*() const & { return object; }
- To volatile& operator*() volatile & { return object; }
- To const volatile& operator*() const volatile & { return object; }
- To&& operator*() && { return static_cast<To &&>(object); }
- To const&& operator*() const && { return static_cast<To const&&>(object); }
- To volatile&& operator*() volatile && { return static_cast<To volatile&&>(object); }
- To const volatile&& operator*() const volatile && { return static_cast<To const volatile&&>(object); }
+ To& operator*() & { return object; }
+ To const& operator*() const& { return object; }
+ To volatile& operator*() volatile& { return object; }
+ To const volatile& operator*() const volatile& { return object; }
+ To&& operator*() && { return static_cast<To&&>(object); }
+ To const&& operator*() const&& { return static_cast<To const&&>(object); }
+ To volatile&& operator*() volatile&& { return static_cast<To volatile&&>(object); }
+ To const volatile&& operator*() const volatile&& { return static_cast<To const volatile&&>(object); }
#endif
};
@@ -192,54 +211,59 @@ struct DerefPropType {
// matches what the method actually returned.
template <class T>
struct MethodID {
- typedef void* IDType;
-
- static int dummy; // A dummy memory location.
- static void* id; // The "ID" is the value of this pointer.
- static bool unchecked_call; // Has a call happened that has not been checked.
-
- static void*& setUncheckedCall() {
- assert(unchecked_call == false);
- unchecked_call = true;
- return id;
- }
-
- static bool checkCalled(void*& return_value) {
- bool old = unchecked_call;
- unchecked_call = false;
- return old && id == return_value && &id == &return_value;
- }
+ typedef void* IDType;
+
+ static int dummy; // A dummy memory location.
+ static void* id; // The "ID" is the value of this pointer.
+ static bool unchecked_call; // Has a call happened that has not been checked.
+
+ static void*& setUncheckedCall() {
+ assert(unchecked_call == false);
+ unchecked_call = true;
+ return id;
+ }
+
+ static bool checkCalled(void*& return_value) {
+ bool old = unchecked_call;
+ unchecked_call = false;
+ return old && id == return_value && &id == &return_value;
+ }
};
-template <class T> int MethodID<T>::dummy = 0;
-template <class T> void* MethodID<T>::id = (void*)&MethodID<T>::dummy;
-template <class T> bool MethodID<T>::unchecked_call = false;
-
+template <class T>
+int MethodID<T>::dummy = 0;
+template <class T>
+void* MethodID<T>::id = (void*)&MethodID<T>::dummy;
+template <class T>
+bool MethodID<T>::unchecked_call = false;
//==============================================================================
// FunctionPtrID - Like MethodID but for free function pointers.
template <class T, T*>
struct FunctionPtrID {
- static int dummy; // A dummy memory location.
- static void* id; // The "ID" is the value of this pointer.
- static bool unchecked_call; // Has a call happened that has not been checked.
-
- static void*& setUncheckedCall() {
- assert(unchecked_call == false);
- unchecked_call = true;
- return id;
- }
-
- static bool checkCalled(void*& return_value) {
- bool old = unchecked_call;
- unchecked_call = false;
- return old && id == return_value && &id == &return_value;
- }
+ static int dummy; // A dummy memory location.
+ static void* id; // The "ID" is the value of this pointer.
+ static bool unchecked_call; // Has a call happened that has not been checked.
+
+ static void*& setUncheckedCall() {
+ assert(unchecked_call == false);
+ unchecked_call = true;
+ return id;
+ }
+
+ static bool checkCalled(void*& return_value) {
+ bool old = unchecked_call;
+ unchecked_call = false;
+ return old && id == return_value && &id == &return_value;
+ }
};
-template <class T, T* Ptr> int FunctionPtrID<T, Ptr>::dummy = 0;
-template <class T, T* Ptr> void* FunctionPtrID<T, Ptr>::id = (void*)&FunctionPtrID<T, Ptr>::dummy;
-template <class T, T* Ptr> bool FunctionPtrID<T, Ptr>::unchecked_call = false;
+template <class T, T* Ptr>
+int FunctionPtrID<T, Ptr>::dummy = 0;
+template <class T, T* Ptr>
+void* FunctionPtrID<T, Ptr>::id = (void*)&FunctionPtrID<T, Ptr>::dummy;
+template <class T, T* Ptr>
+bool FunctionPtrID<T, Ptr>::unchecked_call = false;
//==============================================================================
// BasicTest - The basic test structure for everything except
@@ -248,128 +272,122 @@ template <class T, T* Ptr> bool FunctionPtrID<T, Ptr>::unchecked_call = false;
// Arity - The Arity of the call signature.
// ObjectCaster - The object transformation functor type.
// ArgCaster - The extra argument transformation functor type.
-template <class ID, int Arity, class ObjectCaster = LValueCaster,
- class ArgCaster = LValueCaster>
+template <class ID, int Arity, class ObjectCaster = LValueCaster, class ArgCaster = LValueCaster>
struct BasicTest {
- template <class ObjectT>
- void runTest(ObjectT& object) {
- Int<Arity> A;
- runTestImp(A, object);
- }
-
- template <class MethodPtr, class ObjectT>
- void runTest(MethodPtr ptr, ObjectT& object) {
- Int<Arity> A;
- runTestImp(A, ptr, object);
- }
+ template <class ObjectT>
+ void runTest(ObjectT& object) {
+ Int<Arity> A;
+ runTestImp(A, object);
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTest(MethodPtr ptr, ObjectT& object) {
+ Int<Arity> A;
+ runTestImp(A, ptr, object);
+ }
private:
- typedef void*& CallRet;
- ObjectCaster object_cast;
- ArgCaster arg_cast;
- ArgType a0, a1, a2;
-
- //==========================================================================
- // BULLET 1, 2 AND 3 TEST METHODS
- //==========================================================================
- template <class MethodPtr, class ObjectT>
- void runTestImp(Int<0>, MethodPtr ptr, ObjectT& object) {
- {
- static_assert((std::is_same<
- decltype(std::__invoke(ptr, object_cast(object)))
- , CallRet>::value), "");
- assert(ID::unchecked_call == false);
- CallRet ret = std::__invoke(ptr, object_cast(object));
- assert(ID::checkCalled(ret));
- }
+ typedef void*& CallRet;
+ ObjectCaster object_cast;
+ ArgCaster arg_cast;
+ ArgType a0, a1, a2;
+
+ //==========================================================================
+ // BULLET 1, 2 AND 3 TEST METHODS
+ //==========================================================================
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<0>, MethodPtr ptr, ObjectT& object) {
+ {
+ static_assert((std::is_same< decltype(std::__invoke(ptr, object_cast(object))), CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object));
+ assert(ID::checkCalled(ret));
}
-
- template <class MethodPtr, class ObjectT>
- void runTestImp(Int<1>, MethodPtr ptr, ObjectT& object) {
- {
- static_assert((std::is_same<
- decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0)))
- , CallRet>::value), "");
- assert(ID::unchecked_call == false);
- CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0));
- assert(ID::checkCalled(ret));
- }
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<1>, MethodPtr ptr, ObjectT& object) {
+ {
+ static_assert(
+ (std::is_same< decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0))), CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0));
+ assert(ID::checkCalled(ret));
}
-
- template <class MethodPtr, class ObjectT>
- void runTestImp(Int<2>, MethodPtr ptr, ObjectT& object) {
- {
- static_assert((std::is_same<
- decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1)))
- , CallRet>::value), "");
- assert(ID::unchecked_call == false);
- CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1));
- assert(ID::checkCalled(ret));
- }
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<2>, MethodPtr ptr, ObjectT& object) {
+ {
+ static_assert((std::is_same< decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1))),
+ CallRet>::value),
+ "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1));
+ assert(ID::checkCalled(ret));
}
-
- template <class MethodPtr, class ObjectT>
- void runTestImp(Int<3>, MethodPtr ptr, ObjectT& object) {
- {
- static_assert((std::is_same<
- decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)))
- , CallRet>::value), "");
- assert(ID::unchecked_call == false);
- CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
- assert(ID::checkCalled(ret));
- }
+ }
+
+ template <class MethodPtr, class ObjectT>
+ void runTestImp(Int<3>, MethodPtr ptr, ObjectT& object) {
+ {
+ static_assert(
+ (std::is_same< decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2))),
+ CallRet>::value),
+ "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
+ assert(ID::checkCalled(ret));
}
-
- //==========================================================================
- // BULLET 7 TEST METHODS
- //==========================================================================
- template <class ObjectT>
- void runTestImp(Int<0>, ObjectT& object) {
- {
- static_assert((std::is_same<
- decltype(std::__invoke(object_cast(object)))
- , CallRet>::value), "");
- assert(ID::unchecked_call == false);
- CallRet ret = std::__invoke(object_cast(object));
- assert(ID::checkCalled(ret));
- }
+ }
+
+ //==========================================================================
+ // BULLET 7 TEST METHODS
+ //==========================================================================
+ template <class ObjectT>
+ void runTestImp(Int<0>, ObjectT& object) {
+ {
+ static_assert((std::is_same< decltype(std::__invoke(object_cast(object))), CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object));
+ assert(ID::checkCalled(ret));
}
-
- template <class ObjectT>
- void runTestImp(Int<1>, ObjectT& object) {
- {
- static_assert((std::is_same<
- decltype(std::__invoke(object_cast(object), arg_cast(a0)))
- , CallRet>::value), "");
- assert(ID::unchecked_call == false);
- CallRet ret = std::__invoke(object_cast(object), arg_cast(a0));
- assert(ID::checkCalled(ret));
- }
+ }
+
+ template <class ObjectT>
+ void runTestImp(Int<1>, ObjectT& object) {
+ {
+ static_assert((std::is_same< decltype(std::__invoke(object_cast(object), arg_cast(a0))), CallRet>::value), "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object), arg_cast(a0));
+ assert(ID::checkCalled(ret));
}
-
- template <class ObjectT>
- void runTestImp(Int<2>, ObjectT& object) {
- {
- static_assert((std::is_same<
- decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1)))
- , CallRet>::value), "");
- assert(ID::unchecked_call == false);
- CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1));
- assert(ID::checkCalled(ret));
- }
+ }
+
+ template <class ObjectT>
+ void runTestImp(Int<2>, ObjectT& object) {
+ {
+ static_assert(
+ (std::is_same< decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1))), CallRet>::value),
+ "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1));
+ assert(ID::checkCalled(ret));
}
-
- template <class ObjectT>
- void runTestImp(Int<3>, ObjectT& object) {
- {
- static_assert((std::is_same<
- decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)))
- , CallRet>::value), "");
- assert(ID::unchecked_call == false);
- CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
- assert(ID::checkCalled(ret));
- }
+ }
+
+ template <class ObjectT>
+ void runTestImp(Int<3>, ObjectT& object) {
+ {
+ static_assert(
+ (std::is_same< decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2))),
+ CallRet>::value),
+ "");
+ assert(ID::unchecked_call == false);
+ CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2));
+ assert(ID::checkCalled(ret));
}
+ }
};
#endif // INVOKE_HELPERS_H
diff --git a/libcxx/test/libcxx-03/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp b/libcxx/test/libcxx-03/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp
index 023ed8ddb..6f84cb9ea 100644
--- a/libcxx/test/libcxx-03/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/function.objects/refwrap/layout.binary.compile.pass.cpp
@@ -16,6 +16,8 @@ struct S1 : std::less<int>, std::greater<int> {};
static_assert(sizeof(S1) == 2, "");
-struct S2 : std::less<int> { char c; };
+struct S2 : std::less<int> {
+ char c;
+};
static_assert(sizeof(S2) == 1, "");
diff --git a/libcxx/test/libcxx-03/utilities/function.objects/unord.hash/murmur2_or_cityhash_ubsan_unsigned_overflow_ignored.pass.cpp b/libcxx/test/libcxx-03/utilities/function.objects/unord.hash/murmur2_or_cityhash_ubsan_unsigned_overflow_ignored.pass.cpp
index 11f0724f9..e98d6ec46 100644
--- a/libcxx/test/libcxx-03/utilities/function.objects/unord.hash/murmur2_or_cityhash_ubsan_unsigned_overflow_ignored.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/function.objects/unord.hash/murmur2_or_cityhash_ubsan_unsigned_overflow_ignored.pass.cpp
@@ -21,7 +21,7 @@ typedef std::__murmur2_or_cityhash<std::uint32_t> Hash32;
typedef std::__murmur2_or_cityhash<std::uint64_t> Hash64;
void test(const void* key, int len) {
- for (int i=1; i <= len; ++i) {
+ for (int i = 1; i <= len; ++i) {
Hash32 h1;
Hash64 h2;
DoNotOptimize(h1(key, i));
@@ -33,10 +33,9 @@ int main(int, char**) {
const std::string TestCases[] = {
"abcdaoeuaoeclaoeoaeuaoeuaousaotehu]+}sthoasuthaoesutahoesutaohesutaoeusaoetuhasoetuhaoseutaoseuthaoesutaohes",
"00000000000000000000000000000000000000000000000000000000000000000000000",
- "1237546895+54+4554985416849484213464984765465464654564565645645646546456546546"
- };
- const std::size_t NumCases = sizeof(TestCases)/sizeof(TestCases[0]);
- for (std::size_t i=0; i < NumCases; ++i)
+ "1237546895+54+4554985416849484213464984765465464654564565645645646546456546546"};
+ const std::size_t NumCases = sizeof(TestCases) / sizeof(TestCases[0]);
+ for (std::size_t i = 0; i < NumCases; ++i)
test(TestCases[i].data(), TestCases[i].length());
return 0;
diff --git a/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address.pass.cpp b/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address.pass.cpp
index 60ef98ae9..e319fcead 100644
--- a/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address.pass.cpp
@@ -20,140 +20,143 @@
struct Irrelevant;
struct P1 {
- using element_type = Irrelevant;
- TEST_CONSTEXPR explicit P1(int *p) : p_(p) { }
- TEST_CONSTEXPR int *operator->() const { return p_; }
- int *p_;
+ using element_type = Irrelevant;
+ TEST_CONSTEXPR explicit P1(int* p) : p_(p) {}
+ TEST_CONSTEXPR int* operator->() const { return p_; }
+ int* p_;
};
struct P2 {
- using element_type = Irrelevant;
- TEST_CONSTEXPR explicit P2(int *p) : p_(p) { }
- TEST_CONSTEXPR P1 operator->() const { return p_; }
- P1 p_;
+ using element_type = Irrelevant;
+ TEST_CONSTEXPR explicit P2(int* p) : p_(p) {}
+ TEST_CONSTEXPR P1 operator->() const { return p_; }
+ P1 p_;
};
struct P3 {
- TEST_CONSTEXPR explicit P3(int *p) : p_(p) { }
- int *p_;
+ TEST_CONSTEXPR explicit P3(int* p) : p_(p) {}
+ int* p_;
};
-template<>
+template <>
struct std::pointer_traits<P3> {
- static TEST_CONSTEXPR int *to_address(const P3& p) { return p.p_; }
+ static TEST_CONSTEXPR int* to_address(const P3& p) { return p.p_; }
};
struct P4 {
- TEST_CONSTEXPR explicit P4(int *p) : p_(p) { }
- int *operator->() const; // should never be called
- int *p_;
+ TEST_CONSTEXPR explicit P4(int* p) : p_(p) {}
+ int* operator->() const; // should never be called
+ int* p_;
};
-template<>
+template <>
struct std::pointer_traits<P4> {
- static TEST_CONSTEXPR int *to_address(const P4& p) { return p.p_; }
+ static TEST_CONSTEXPR int* to_address(const P4& p) { return p.p_; }
};
struct P5 {
- using element_type = Irrelevant;
- int const* const& operator->() const;
+ using element_type = Irrelevant;
+ int const* const& operator->() const;
};
struct P6 {};
-template<>
+template <>
struct std::pointer_traits<P6> {
- static int const* const& to_address(const P6&);
+ static int const* const& to_address(const P6&);
};
// Taken from a build breakage caused in Clang
namespace P7 {
- template<typename T> struct CanProxy;
- template<typename T>
- struct CanQual {
- CanProxy<T> operator->() const { return CanProxy<T>(); }
- };
- template<typename T>
- struct CanProxy {
- const CanProxy<T> *operator->() const { return nullptr; }
- };
+template <typename T>
+struct CanProxy;
+template <typename T>
+struct CanQual {
+ CanProxy<T> operator->() const { return CanProxy<T>(); }
+};
+template <typename T>
+struct CanProxy {
+ const CanProxy<T>* operator->() const { return nullptr; }
+};
} // namespace P7
namespace P8 {
- template<class T>
- struct FancyPtrA {
- using element_type = Irrelevant;
- T *p_;
- TEST_CONSTEXPR FancyPtrA(T *p) : p_(p) {}
- T& operator*() const;
- TEST_CONSTEXPR T *operator->() const { return p_; }
- };
- template<class T>
- struct FancyPtrB {
- T *p_;
- TEST_CONSTEXPR FancyPtrB(T *p) : p_(p) {}
- T& operator*() const;
- };
+template <class T>
+struct FancyPtrA {
+ using element_type = Irrelevant;
+ T* p_;
+ TEST_CONSTEXPR FancyPtrA(T* p) : p_(p) {}
+ T& operator*() const;
+ TEST_CONSTEXPR T* operator->() const { return p_; }
+};
+template <class T>
+struct FancyPtrB {
+ T* p_;
+ TEST_CONSTEXPR FancyPtrB(T* p) : p_(p) {}
+ T& operator*() const;
+};
} // namespace P8
-template<class T>
+template <class T>
struct std::pointer_traits<P8::FancyPtrB<T> > {
- static TEST_CONSTEXPR T *to_address(const P8::FancyPtrB<T>& p) { return p.p_; }
+ static TEST_CONSTEXPR T* to_address(const P8::FancyPtrB<T>& p) { return p.p_; }
};
struct Incomplete;
-template<class T> struct Holder { T t; };
-
+template <class T>
+struct Holder {
+ T t;
+};
TEST_CONSTEXPR_CXX14 bool test() {
- int i = 0;
- ASSERT_NOEXCEPT(std::__to_address(&i));
- assert(std::__to_address(&i) == &i);
- P1 p1(&i);
- ASSERT_NOEXCEPT(std::__to_address(p1));
- assert(std::__to_address(p1) == &i);
- P2 p2(&i);
- ASSERT_NOEXCEPT(std::__to_address(p2));
- assert(std::__to_address(p2) == &i);
- P3 p3(&i);
- ASSERT_NOEXCEPT(std::__to_address(p3));
- assert(std::__to_address(p3) == &i);
- P4 p4(&i);
- ASSERT_NOEXCEPT(std::__to_address(p4));
- assert(std::__to_address(p4) == &i);
-
- ASSERT_SAME_TYPE(decltype(std::__to_address(std::declval<int const*>())), int const*);
- ASSERT_SAME_TYPE(decltype(std::__to_address(std::declval<P5>())), int const*);
- ASSERT_SAME_TYPE(decltype(std::__to_address(std::declval<P6>())), int const*);
-
- P7::CanQual<int>* p7 = nullptr;
- assert(std::__to_address(p7) == nullptr);
- ASSERT_SAME_TYPE(decltype(std::__to_address(p7)), P7::CanQual<int>*);
-
- Holder<Incomplete> *p8_nil = nullptr; // for C++03 compatibility
- P8::FancyPtrA<Holder<Incomplete> > p8a = p8_nil;
- assert(std::__to_address(p8a) == p8_nil);
- ASSERT_SAME_TYPE(decltype(std::__to_address(p8a)), decltype(p8_nil));
-
- P8::FancyPtrB<Holder<Incomplete> > p8b = p8_nil;
- assert(std::__to_address(p8b) == p8_nil);
- ASSERT_SAME_TYPE(decltype(std::__to_address(p8b)), decltype(p8_nil));
-
- int p9[2] = {};
- assert(std::__to_address(p9) == p9);
- ASSERT_SAME_TYPE(decltype(std::__to_address(p9)), int*);
-
- const int p10[2] = {};
- assert(std::__to_address(p10) == p10);
- ASSERT_SAME_TYPE(decltype(std::__to_address(p10)), const int*);
-
- return true;
+ int i = 0;
+ ASSERT_NOEXCEPT(std::__to_address(&i));
+ assert(std::__to_address(&i) == &i);
+ P1 p1(&i);
+ ASSERT_NOEXCEPT(std::__to_address(p1));
+ assert(std::__to_address(p1) == &i);
+ P2 p2(&i);
+ ASSERT_NOEXCEPT(std::__to_address(p2));
+ assert(std::__to_address(p2) == &i);
+ P3 p3(&i);
+ ASSERT_NOEXCEPT(std::__to_address(p3));
+ assert(std::__to_address(p3) == &i);
+ P4 p4(&i);
+ ASSERT_NOEXCEPT(std::__to_address(p4));
+ assert(std::__to_address(p4) == &i);
+
+ ASSERT_SAME_TYPE(decltype(std::__to_address(std::declval<int const*>())), int const*);
+ ASSERT_SAME_TYPE(decltype(std::__to_address(std::declval<P5>())), int const*);
+ ASSERT_SAME_TYPE(decltype(std::__to_address(std::declval<P6>())), int const*);
+
+ P7::CanQual<int>* p7 = nullptr;
+ assert(std::__to_address(p7) == nullptr);
+ ASSERT_SAME_TYPE(decltype(std::__to_address(p7)), P7::CanQual<int>*);
+
+ Holder<Incomplete>* p8_nil = nullptr; // for C++03 compatibility
+ P8::FancyPtrA<Holder<Incomplete> > p8a = p8_nil;
+ assert(std::__to_address(p8a) == p8_nil);
+ ASSERT_SAME_TYPE(decltype(std::__to_address(p8a)), decltype(p8_nil));
+
+ P8::FancyPtrB<Holder<Incomplete> > p8b = p8_nil;
+ assert(std::__to_address(p8b) == p8_nil);
+ ASSERT_SAME_TYPE(decltype(std::__to_address(p8b)), decltype(p8_nil));
+
+ int p9[2] = {};
+ assert(std::__to_address(p9) == p9);
+ ASSERT_SAME_TYPE(decltype(std::__to_address(p9)), int*);
+
+ const int p10[2] = {};
+ assert(std::__to_address(p10) == p10);
+ ASSERT_SAME_TYPE(decltype(std::__to_address(p10)), const int*);
+
+ return true;
}
int main(int, char**) {
- test();
+ test();
#if TEST_STD_VER >= 14
- static_assert(test(), "");
+ static_assert(test(), "");
#endif
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_funcptr.verify.cpp b/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_funcptr.verify.cpp
index 02b167605..363172ef3 100644
--- a/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_funcptr.verify.cpp
+++ b/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_funcptr.verify.cpp
@@ -16,5 +16,5 @@
int (*pf)();
void test() {
- (void)std::__to_address(pf); // expected-error@*:* {{is a function type}}
+ (void)std::__to_address(pf); // expected-error@*:* {{is a function type}}
}
diff --git a/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_function.verify.cpp b/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_function.verify.cpp
index b8825a181..4f2d4c52a 100644
--- a/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_function.verify.cpp
+++ b/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_on_function.verify.cpp
@@ -16,5 +16,5 @@
int f();
void test() {
- (void)std::__to_address(f); // expected-error@*:* {{is a function type}}
+ (void)std::__to_address(f); // expected-error@*:* {{is a function type}}
}
diff --git a/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp b/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp
index 5eed12d19..6c4c4c8e8 100644
--- a/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp
@@ -22,35 +22,33 @@
#include <vector>
#include "test_macros.h"
-template<class C>
-void test_container_iterators(C c)
-{
- const C& cc = c;
- assert(std::__to_address(c.begin()) == c.data());
- assert(std::__to_address(c.end()) == c.data() + c.size());
- assert(std::__to_address(cc.begin()) == cc.data());
- assert(std::__to_address(cc.end()) == cc.data() + cc.size());
+template <class C>
+void test_container_iterators(C c) {
+ const C& cc = c;
+ assert(std::__to_address(c.begin()) == c.data());
+ assert(std::__to_address(c.end()) == c.data() + c.size());
+ assert(std::__to_address(cc.begin()) == cc.data());
+ assert(std::__to_address(cc.end()) == cc.data() + cc.size());
}
-void test_valarray_iterators()
-{
- std::valarray<int> v(100);
- int *p = std::__to_address(std::begin(v));
- int *q = std::__to_address(std::end(v));
- assert(q - p == 100);
+void test_valarray_iterators() {
+ std::valarray<int> v(100);
+ int* p = std::__to_address(std::begin(v));
+ int* q = std::__to_address(std::end(v));
+ assert(q - p == 100);
}
int main(int, char**) {
- test_container_iterators(std::array<int, 3>());
- test_container_iterators(std::vector<int>(3));
- test_container_iterators(std::string("abc"));
+ test_container_iterators(std::array<int, 3>());
+ test_container_iterators(std::vector<int>(3));
+ test_container_iterators(std::string("abc"));
#if TEST_STD_VER >= 17
- test_container_iterators(std::string_view("abc"));
+ test_container_iterators(std::string_view("abc"));
#endif
#if TEST_STD_VER >= 20
- test_container_iterators(std::span<const char>("abc"));
+ test_container_iterators(std::span<const char>("abc"));
#endif
- test_valarray_iterators();
+ test_valarray_iterators();
- return 0;
+ return 0;
}
diff --git a/libcxx/test/libcxx-03/utilities/meta/meta_base.pass.cpp b/libcxx/test/libcxx-03/utilities/meta/meta_base.pass.cpp
index 66c25b1d7..df62c79d7 100644
--- a/libcxx/test/libcxx-03/utilities/meta/meta_base.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/meta/meta_base.pass.cpp
@@ -26,7 +26,7 @@ struct BOOM {
using Explode = typename T::BOOMBOOM;
};
-using True = std::true_type;
+using True = std::true_type;
using False = std::false_type;
void test_if() {
@@ -87,6 +87,4 @@ void test_is_valid_trait() {
static_assert(!std::_IsValidExpansion<FuncCallable, MemberTest, void*>::value, "");
}
-int main(int, char**) {
- return 0;
-}
+int main(int, char**) { return 0; }
diff --git a/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp b/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp
index 1f5dae123..7df3707b6 100644
--- a/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.non_trivial_copy_move.pass.cpp
@@ -28,127 +28,128 @@
#include "test_macros.h"
template <class T>
-struct HasNonTrivialABI : std::integral_constant<bool,
- !std::is_trivially_destructible<T>::value
- || (std::is_copy_constructible<T>::value && !std::is_trivially_copy_constructible<T>::value)
+struct HasNonTrivialABI
+ : std::integral_constant<
+ bool,
+ !std::is_trivially_destructible<T>::value ||
+ (std::is_copy_constructible<T>::value && !std::is_trivially_copy_constructible<T>::value)
#if TEST_STD_VER >= 11
- || (std::is_move_constructible<T>::value && !std::is_trivially_move_constructible<T>::value)
+ || (std::is_move_constructible<T>::value && !std::is_trivially_move_constructible<T>::value)
#endif
-> {};
+ > {
+};
#if TEST_STD_VER >= 11
struct NonTrivialDtor {
- NonTrivialDtor(NonTrivialDtor const&) = default;
- ~NonTrivialDtor();
+ NonTrivialDtor(NonTrivialDtor const&) = default;
+ ~NonTrivialDtor();
};
NonTrivialDtor::~NonTrivialDtor() {}
static_assert(HasNonTrivialABI<NonTrivialDtor>::value, "");
struct NonTrivialCopy {
- NonTrivialCopy(NonTrivialCopy const&);
+ NonTrivialCopy(NonTrivialCopy const&);
};
NonTrivialCopy::NonTrivialCopy(NonTrivialCopy const&) {}
static_assert(HasNonTrivialABI<NonTrivialCopy>::value, "");
struct NonTrivialMove {
- NonTrivialMove(NonTrivialMove const&) = default;
- NonTrivialMove(NonTrivialMove&&);
+ NonTrivialMove(NonTrivialMove const&) = default;
+ NonTrivialMove(NonTrivialMove&&);
};
NonTrivialMove::NonTrivialMove(NonTrivialMove&&) {}
static_assert(HasNonTrivialABI<NonTrivialMove>::value, "");
struct DeletedCopy {
- DeletedCopy(DeletedCopy const&) = delete;
- DeletedCopy(DeletedCopy&&) = default;
+ DeletedCopy(DeletedCopy const&) = delete;
+ DeletedCopy(DeletedCopy&&) = default;
};
static_assert(!HasNonTrivialABI<DeletedCopy>::value, "");
struct TrivialMove {
- TrivialMove(TrivialMove &&) = default;
+ TrivialMove(TrivialMove&&) = default;
};
static_assert(!HasNonTrivialABI<TrivialMove>::value, "");
struct Trivial {
- Trivial(Trivial const&) = default;
+ Trivial(Trivial const&) = default;
};
static_assert(!HasNonTrivialABI<Trivial>::value, "");
#endif
-
-void test_trivial()
-{
- {
- typedef std::pair<int, short> P;
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(HasNonTrivialABI<P>::value, "");
- }
+void test_trivial() {
+ {
+ typedef std::pair<int, short> P;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(HasNonTrivialABI<P>::value, "");
+ }
#if TEST_STD_VER >= 11
- {
- typedef std::pair<int, short> P;
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(HasNonTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<NonTrivialDtor, int>;
- static_assert(!std::is_trivially_destructible<P>::value, "");
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
- static_assert(HasNonTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<NonTrivialCopy, int>;
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
- static_assert(HasNonTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<NonTrivialMove, int>;
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
- static_assert(HasNonTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<DeletedCopy, int>;
- static_assert(!std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
- static_assert(HasNonTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<Trivial, int>;
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
- static_assert(HasNonTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<TrivialMove, int>;
- static_assert(!std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
- static_assert(HasNonTrivialABI<P>::value, "");
- }
+ {
+ typedef std::pair<int, short> P;
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(HasNonTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<NonTrivialDtor, int>;
+ static_assert(!std::is_trivially_destructible<P>::value, "");
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasNonTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<NonTrivialCopy, int>;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasNonTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<NonTrivialMove, int>;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasNonTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<DeletedCopy, int>;
+ static_assert(!std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasNonTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<Trivial, int>;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasNonTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<TrivialMove, int>;
+ static_assert(!std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasNonTrivialABI<P>::value, "");
+ }
#endif
}
void test_layout() {
- typedef std::pair<std::pair<char, char>, char> PairT;
- static_assert(sizeof(PairT) == 3, "");
- static_assert(TEST_ALIGNOF(PairT) == TEST_ALIGNOF(char), "");
- static_assert(offsetof(PairT, first) == 0, "");
+ typedef std::pair<std::pair<char, char>, char> PairT;
+ static_assert(sizeof(PairT) == 3, "");
+ static_assert(TEST_ALIGNOF(PairT) == TEST_ALIGNOF(char), "");
+ static_assert(offsetof(PairT, first) == 0, "");
}
int main(int, char**) {
- test_trivial();
- test_layout();
- return 0;
+ test_trivial();
+ test_layout();
+ return 0;
}
diff --git a/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.trivial_copy_move.pass.cpp b/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.trivial_copy_move.pass.cpp
index 3ec60c08b..2cd6cb7b0 100644
--- a/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.trivial_copy_move.pass.cpp
+++ b/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/abi.trivial_copy_move.pass.cpp
@@ -25,48 +25,51 @@
#include "test_macros.h"
template <class T>
-struct HasTrivialABI : std::integral_constant<bool,
- std::is_trivially_destructible<T>::value
- && (!std::is_copy_constructible<T>::value || std::is_trivially_copy_constructible<T>::value)
+struct HasTrivialABI
+ : std::integral_constant<
+ bool,
+ std::is_trivially_destructible<T>::value &&
+ (!std::is_copy_constructible<T>::value || std::is_trivially_copy_constructible<T>::value)
#if TEST_STD_VER >= 11
- && (!std::is_move_constructible<T>::value || std::is_trivially_move_constructible<T>::value)
+ && (!std::is_move_constructible<T>::value || std::is_trivially_move_constructible<T>::value)
#endif
-> {};
+ > {
+};
#if TEST_STD_VER >= 11
struct NonTrivialDtor {
- NonTrivialDtor(NonTrivialDtor const&) = default;
- ~NonTrivialDtor();
+ NonTrivialDtor(NonTrivialDtor const&) = default;
+ ~NonTrivialDtor();
};
NonTrivialDtor::~NonTrivialDtor() {}
static_assert(!HasTrivialABI<NonTrivialDtor>::value, "");
struct NonTrivialCopy {
- NonTrivialCopy(NonTrivialCopy const&);
+ NonTrivialCopy(NonTrivialCopy const&);
};
NonTrivialCopy::NonTrivialCopy(NonTrivialCopy const&) {}
static_assert(!HasTrivialABI<NonTrivialCopy>::value, "");
struct NonTrivialMove {
- NonTrivialMove(NonTrivialMove const&) = default;
- NonTrivialMove(NonTrivialMove&&);
+ NonTrivialMove(NonTrivialMove const&) = default;
+ NonTrivialMove(NonTrivialMove&&);
};
NonTrivialMove::NonTrivialMove(NonTrivialMove&&) {}
static_assert(!HasTrivialABI<NonTrivialMove>::value, "");
struct DeletedCopy {
- DeletedCopy(DeletedCopy const&) = delete;
- DeletedCopy(DeletedCopy&&) = default;
+ DeletedCopy(DeletedCopy const&) = delete;
+ DeletedCopy(DeletedCopy&&) = default;
};
static_assert(HasTrivialABI<DeletedCopy>::value, "");
struct TrivialMove {
- TrivialMove(TrivialMove &&) = default;
+ TrivialMove(TrivialMove&&) = default;
};
static_assert(HasTrivialABI<TrivialMove>::value, "");
struct Trivial {
- Trivial(Trivial const&) = default;
+ Trivial(Trivial const&) = default;
};
static_assert(HasTrivialABI<Trivial>::value, "");
#endif
@@ -83,100 +86,99 @@ struct TrivialNoConstruction {
TrivialNoConstruction& operator=(const TrivialNoConstruction&) = default;
};
-void test_trivial()
-{
- {
- typedef std::pair<int, short> P;
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(HasTrivialABI<P>::value, "");
- }
+void test_trivial() {
+ {
+ typedef std::pair<int, short> P;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
#if TEST_STD_VER >= 11
- {
- typedef std::pair<int, short> P;
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(HasTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<NonTrivialDtor, int>;
- static_assert(!std::is_trivially_destructible<P>::value, "");
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
- static_assert(!HasTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<NonTrivialCopy, int>;
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
- static_assert(!HasTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<NonTrivialMove, int>;
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
- static_assert(!HasTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<DeletedCopy, int>;
- static_assert(!std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(std::is_trivially_move_constructible<P>::value, "");
- static_assert(HasTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<Trivial, int>;
- static_assert(std::is_copy_constructible<P>::value, "");
- static_assert(std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(std::is_trivially_move_constructible<P>::value, "");
- static_assert(HasTrivialABI<P>::value, "");
- }
- {
- using P = std::pair<TrivialMove, int>;
- static_assert(!std::is_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_move_constructible<P>::value, "");
- static_assert(std::is_trivially_move_constructible<P>::value, "");
- static_assert(HasTrivialABI<P>::value, "");
- }
+ {
+ typedef std::pair<int, short> P;
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<NonTrivialDtor, int>;
+ static_assert(!std::is_trivially_destructible<P>::value, "");
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(!HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<NonTrivialCopy, int>;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(!HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<NonTrivialMove, int>;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(!HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<DeletedCopy, int>;
+ static_assert(!std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<Trivial, int>;
+ static_assert(std::is_copy_constructible<P>::value, "");
+ static_assert(std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
+ {
+ using P = std::pair<TrivialMove, int>;
+ static_assert(!std::is_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_move_constructible<P>::value, "");
+ static_assert(std::is_trivially_move_constructible<P>::value, "");
+ static_assert(HasTrivialABI<P>::value, "");
+ }
#endif
- {
- using P = std::pair<TrivialNoAssignment, int>;
- static_assert(std::is_trivially_copy_constructible<P>::value, "");
- static_assert(std::is_trivially_move_constructible<P>::value, "");
+ {
+ using P = std::pair<TrivialNoAssignment, int>;
+ static_assert(std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(std::is_trivially_move_constructible<P>::value, "");
#if TEST_STD_VER >= 11 // This is https://llvm.org/PR90605
- static_assert(!std::is_trivially_copy_assignable<P>::value, "");
- static_assert(!std::is_trivially_move_assignable<P>::value, "");
+ static_assert(!std::is_trivially_copy_assignable<P>::value, "");
+ static_assert(!std::is_trivially_move_assignable<P>::value, "");
#endif // TEST_STD_VER >= 11
- static_assert(std::is_trivially_destructible<P>::value, "");
- }
- {
- using P = std::pair<TrivialNoConstruction, int>;
+ static_assert(std::is_trivially_destructible<P>::value, "");
+ }
+ {
+ using P = std::pair<TrivialNoConstruction, int>;
#if TEST_STD_VER >= 11
- static_assert(!std::is_trivially_copy_constructible<P>::value, "");
- static_assert(!std::is_trivially_move_constructible<P>::value, "");
+ static_assert(!std::is_trivially_copy_constructible<P>::value, "");
+ static_assert(!std::is_trivially_move_constructible<P>::value, "");
#endif // TEST_STD_VER >= 11
- static_assert(!std::is_trivially_copy_assignable<P>::value, "");
- static_assert(!std::is_trivially_move_assignable<P>::value, "");
- static_assert(std::is_trivially_destructible<P>::value, "");
- }
+ static_assert(!std::is_trivially_copy_assignable<P>::value, "");
+ static_assert(!std::is_trivially_move_assignable<P>::value, "");
+ static_assert(std::is_trivially_destructible<P>::value, "");
+ }
}
void test_layout() {
- typedef std::pair<std::pair<char, char>, char> PairT;
- static_assert(sizeof(PairT) == 3, "");
- static_assert(TEST_ALIGNOF(PairT) == TEST_ALIGNOF(char), "");
- static_assert(offsetof(PairT, first) == 0, "");
+ typedef std::pair<std::pair<char, char>, char> PairT;
+ static_assert(sizeof(PairT) == 3, "");
+ static_assert(TEST_ALIGNOF(PairT) == TEST_ALIGNOF(char), "");
+ static_assert(offsetof(PairT, first) == 0, "");
}
int main(int, char**) {
- test_trivial();
- test_layout();
- return 0;
+ test_trivial();
+ test_layout();
+ return 0;
}
diff --git a/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/pair.tuple_element.verify.cpp b/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/pair.tuple_element.verify.cpp
index 7d10d8b23..4291b4aea 100644
--- a/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/pair.tuple_element.verify.cpp
+++ b/libcxx/test/libcxx-03/utilities/utility/pairs/pairs.pair/pair.tuple_element.verify.cpp
@@ -17,5 +17,5 @@
void f() {
typedef std::pair<int, double> P;
std::tuple_element<2, P>::type foo; // expected-note {{requested here}}
- // expected-error-re@*:* {{static assertion failed{{( due to requirement '2U[L]{0,2} < 2')?}}{{.*}}Index out of bounds in std::tuple_element<std::pair<T1, T2>>}}
+ // expected-error-re@*:* {{static assertion failed{{( due to requirement '2U[L]{0,2} < 2')?}}{{.*}}Index out of bounds in std::tuple_element<std::pair<T1, T2>>}}
}
|
The C++03 headers are essentially a separate implementation, so it doesn't make a ton of sense to try to test two implementations with a single set of implementation-specific tests.
This patch doesn't copy over any tests that will not be run in C++03 mode. The most notable changes are that
lit.local.cfg
files are touched to change the path fromlibcxx/test/libcxx
tolibcxx/test/libcxx-03
in a few places.This also modifies
lit.local.cfg
files to runlibcxx/test/libcxx-03
only when using the frozen headers andlbcxx/test/libcxx
tests only when not using the frozen headers.This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc.